jed-users mailing list

[2003 Date Index] [2003 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: Some questions


Joerg Sommer <joerg@xxxxxxxxxxxx> wrote:
>Is there any advantage in use the polish syntax?

The main advantage is that the preparsing step is skipped.  The
preparser converts the infix notation (a+b) to RPN (a b +).  The
downside is that some of the higher level constructs cannot be
expressed in S-Lang's RPN notation.   For example, consider

   define foo ()
   {
      _pop_n (_NARGS);
      vmessage ("_NARGS = %d", _NARGS);
   }

Calling this function using

   foo (1,2,3);

will result in _NARGS = 3.  However, calling it with

   . 1 2 3 foo

results in _NARGS = 0.  This is because the preparser generates extra
code to compute the number of arguments passed to the function.
S-Lang v2 will produce even more code.  Consider:

   define foo ()
   {
      _pop_n (_NARGS);
      vmessage ("_NARGS = %d", _NARGS);
      return 1;
   }

Calling it via 

   foo (1, 2, 3);

with the current versioon of S-Lang will result in 1 being left on the
stack.  However, S-Lang 2 will generate code to silently remove the
1 from the stack.  S-Lang 2 will introduce an operator called __push
that may be used to override this behavior:

   foo (1,2,3);               % ==> nothing on stack
   __push foo (1, 2, 3);      % ==> 1 left on stack

   1;                         % a statement with no effect
   __push 1;                  % 1 left on stack

For many, this will be a welcome change.

Thanks,
--John







   

-- 
John E. Davis                   Center for Space Research/AXAF Science Center
617-258-8119                    One Hampshire St., Building NE80-6019
http://space.mit.edu/~davis     Cambridge, MA  02139-4307

--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.


[2003 date index] [2003 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]