On Sun, 30 Dec 2007 22:44:45 +1300
"Chris Double" <[EMAIL PROTECTED]> wrote:

> I've heard a newcomer or two mention difficulty in the past in
> understanding why some words leave their arguments on the stack and
> some don't. They seem to prefer a convention of one way or another to
> make it easier to remember.

This is more or less what I've been thinking.  It doesn't matter which
is chosen, or even if words do both, so long as there's a short rule
set that I can use to infer what the word does from it's name or
usage.  As it stands now many words just seem to be written to fit
their first usage and oddly don't conform to any documented standard.

My preference would be a set of rules like this (not exactly like
this of course):

1) Words that operate on the data or retain stack work as documented
(dup, dupd, swap, etc.)
2) Words that operate on data types leave (especially as "transforms")
them on the stack or a transformed version. That's tuples, vectors,
hashes, etc. and words like push, >string, etc.  Words like at also fit
this way by transforming their inputs to a single output.
3) Alternative words for rule #2 that don't leave them on the stack end
in !.  This would be used in the least common cases and would be a way
to say "watch out!".
4) Conditions always remove from the stack on both true and false,
unless they have *.
5) Other words that are meant for doing arbitrary operations will have
to be looked up, but if they emulate any of the above they should follow
that protocol.

This is just off the top of my head, but if the rules were laid out
like this then I could at least not have to memorize or look up every
single word I have to use.  I could infer it at any time.  I could also
spot words that were "weird" and we could either update the rules or
change the word to fit the protocol.

I guess it just seems stupid to me to constantly have to "keep" things
and use "over" when that's the 90% common case usage.

-- 
Zed A. Shaw
- Hate: http://savingtheinternetwithhate.com/
- Good: http://www.zedshaw.com/
- Evil: http://yearofevil.com/

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to