On Mon, Dec 19, 2011 at 4:09 AM, Joe Groff <[email protected]> wrote:
> On Sun, Dec 18, 2011 at 2:32 PM, P. <[email protected]> wrote:
>
>> I've wondered the same. Theoretically, since Factor can infer stack
>> effects, one should be able to leave them out.
>>
>
> Stack effects can't be fully inferred in a safe manner. I forget the full
> details, but somewhere in the archives or his blog, Slava explains why
> stack effects are mandatory. Also, reading source code without declared
> stack effects is a few orders of magnitude more difficult, and writing it
> is more bug-prone.
>
> -Joe
>
Well, it certainly is possible for some subset of definitions. Here's a
quick hack based on definition of \ : just to try it:
> USING: kernel parser stack-checker words ;
> IN: autoinfer
>
> : (AUTO:) ( -- word def effect ) CREATE-WORD parse-definition dup infer ;
>
> SYNTAX: AUTO: (AUTO:) define-declared ;
>
But as Joe points out, declaring stack effects catches bugs early and adds
a bit of self-documenting to the code, so it's not something you should use
in maintainable code.
------------------------------------------------------------------------------
Learn Windows Azure Live! Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for
developers. It will provide a great way to learn Windows Azure and what it
provides. You can attend the event by watching it streamed LIVE online.
Learn more at http://p.sf.net/sfu/ms-windowsazure
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk