Slava Pestov wrote:

> I don't like the ! suffix because it overlaps with comments. What
> about past tense to denote mutation?

Heh, it's funny that you bring up past tense. In the 'newfx' vocabulary I use 
it to denote word variants with a 'mutate and drop' effect. So for example:

        suffix    ( seq elt -- seq )
        suffix!   ( seq elt -- seq )
        suffixed! ( seq elt --     )

If a different effect order turns out to come up often enough, I'll have those 
defined as well:

        : suffix-on    ( elt seq -- seq ) swap suffix ;
        : suffix-on!   ( elt seq -- seq ) tuck sequences:push ;
        : suffixed-on! ( elt seq --     )      sequences:push ;

I use these conventions consistently throughout 'newfx'.

The idea taken from natural languages is that of a "root word". In the above 
case it's 'suffix'. With conventions such as these, you can teach a Factor 
student about a certain "root word" and they can infer the existence of (and 
guess the name of) the variants. Or, when they're reading code, if they see a 
word based on a root they know, they'll understand what's going on.

Another example of a word set based on a single root is 'pluck' which is the 
name I use for 'remove-nth':

        : pluck         ( seq i   -- seq ) cut-slice rest-slice append ;
        : pluck-from    ( i   seq -- seq ) swap pluck ;
        : pluck!        ( seq i   -- seq ) over delete-nth ;
        : pluck-from!   ( i   seq -- seq ) tuck delete-nth ;
        : plucked!      ( seq i   --     ) swap delete-nth ;
        : plucked-from! ( i   seq --     )      delete-nth ;

The only two which are essential are: 'pluck' and 'pluck!'. All the others are 
stack effect variants.

Ed

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to