The major feature of Forth is that it allows the programmer to write code
that executes at compile-time. To a large extent, this is not necessary in
Factor because the structure statements (if, while, etc.) use quots, and it
is possible to write your own in a similar manner.
I still see a need for writing compile-time code though. For example, in
ANS-Forth enum is not part of the standard, but writing it is easy (and is a
typical assignment for Forth students):
: enum ( n -- new-n )
dup constant
1+ ;
It is used like this:
0
enum large
enum extra
enum huge
enum massive
drop
The reason why I am struggling with Factor is that I'm not accustomed to
looking things up in the documentation. In Forth I wouldn't even consider
looking up something like enum to find out if it is included in the language
or in the libraries; I would just write it myself. In most computer jobs, an
"expert" is somebody who has familiarized himself with a massive library of
functions (such as enum) and therefore can write code without having to
continually look things up in the documentation. In Forth, the concept of
expertise is pretty-much meaningless because spending too much time looking
things up is not the typical reason why people fail at their job.
Does Factor provide any facility for writing compile-time code? The enum
example was very simple, but this idea can be expanded upon to build
something similar to C's structs, or even an OOP package. Forth is very
extensible. By comparison, to extend C to include OOP you would have to
write a preprocessor (as Brad Cox did to invent Objective-C), and you would
have to eventually upgrade the compiler (as done in GCC) so that your
debugger continues to work, and the error-messages continue to make sense
(at least as much as they ever did), and so forth. This is way beyond most
people's means.
>
> Message: 6
> Date: Fri, 11 Sep 2009 00:16:35 -0500
> From: [email protected]
> Subject: Re: [Factor-talk] confusion
> To: "[email protected]"
> <[email protected]>
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset=us-ascii; format=flowed; delsp=yes
>
> SYMBOLS: large xtra huge massive ;
>
> You can case off these:
>
> : fill-drink ( drink size -- )
> {
> { large [ .3 fill-it ] }
> ...
> } case ;
>
> This way there are no Funny numbers to deal with, just symbols.
>
> For method dispatch, make singletons instead.
>
> Doug
>
------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk