Thoughts on Named Primitive Plugins

Andrew C. Greenberg werdna at gate.net
Mon Mar 1 13:23:39 UTC 1999


In a recent e-mail, I was asked why should anyone produce an external 
library, such as rePlugin, that links to a program that could 
obviously be coded in Smalltalk, since the latter would be more 
reuseable.

A salient point.  However, I have an answer in the case of a regular 
expression libary.

I was unable to find a readily usable Smalltalk library with all of 
the functionality and performance of PCRE, and wasn't inclined at 
this moment to write one myself.  I am not sure that adapting an 
existing Smalltalk library not specifically designed to be a Squeak 
plugin is a cakewalk either.

My key reasons for building rePlugin were these:

	(1) There is an active ongoing OSS constituency that 
maintains and updates PCRE, with a solid track record.  The library 
is fully functional, up to speed with contemporary Perl-style 
semantics, fast for a "Traditional NFA" regexp library, and is likely 
to be kept up to date.  Maintaining a parallel track in a different 
language seems to me wasteful.  Philip Hazel did an excellent job in 
producing and maintaing PCRE over many years, which is why Guido 
adopted it in Python to replace his regex library, even though there 
was a substantial existing base of code using regex.

	(2) To show one way that integrating such a library can be 
done for Squeak in OSS-land.  Note that the code here is readily 
adaptable to a variety of existing libraries; and that the code still 
works even though the library makes use of malloc/free.

[PCRE is a gentle library in this regard, in that its memory 
allocation is well-localized, and the buffers it produces contain 
relocatable data that can then be loaded into a Squeak ByteArray -- a 
more nasty package in this sense (such as Gnu's rx library) requires 
a "two worlds" approach, complete with finalization, startUp and 
shutDown issues.  I chose PCRE primarily because I can't deal with 
the Posix re syntax, but also for this reason as well.]

I have also built a PluginPlugin, for connecting to standalone 
preexisting shared libraries for hacking to C from Squeak.  Its still 
not ready for prime-time, but works just fine in my existing tests. 
Write if you are interested.

My next project is slightly more ambitious, but I think achievable 
and possibly quite useful -- Tk.





More information about the Squeak-dev mailing list