text.slate namespace and traits question

Brian Rice water at tunes.org
Tue May 30 02:52:46 PDT 2006


On May 29, 2006, at 9:19 PM, Timmy Douglas wrote:

> I have some questions. It's about this code in text.slate:

text.slate shouldn't be taken too seriously except as an attempt to  
outline a system of text manipulation that is NOT as cruddy as  
Squeak's, and is in fact a little more emacs-ish without those  
limits, either.

> prototypes ensureNamespace: #text &delegate: True.
>
> text define: #BufferPointer &parents: {Comparable}.
> text define: #TextBuffer &parents: {Cloneable} &slots: {#lines}.
>
> TextBuffer traits define: #Pointer &parents: {BufferPointer}
>  &slots: {#line. #position}.
>
> Why is the namespace lowercase? I thought the convention was
> uppercase for namespaces.. but 'prototypes' is lower case also. I
> don't see anything in the manual.

Eh, mostly my convention is that anything that seems like a proper  
name versus a name for a generic class of things should be uppercase  
vs. lowercase. Or if I wanted a type Text, and related types, I would  
put it in "text" vs. "Text" so that there would be less ambiguity.

> Also, I don't think I understand why #Pointer is defined in the traits
> object. Why not in the text namespace like everything else?  I guess
> this would give theme similar traits hierarchies, but it's hard for me
> to imagine how to use this. It'd be nice if I could get an example...

It's for pointers into text buffers, like an index into a Sequence.  
The point of it is that one could write other text buffer types or  
implementations, and have a polymorphic set of pointer types for each  
one.

It's the same reason that Set ReadStream and Bag ReadStream exist as  
defined on their traits objects, so that only one method need be  
called "reader" which does the same thing for all objects/collections.

--
-Brian
http://tunes.org/~water/brice.vcf

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
Url : /archives/slate/attachments/20060530/0b3515be/PGP.pgp


More information about the Slate mailing list