# Re: [stack] comments - 6

## Louis Madon — 2000-07-27 11:42:02

    phimvt@... wrote:

     > 4.  There seems to be some demand for being able to manipulate

    > lists ins very general way. In Joy there is the  infra  combinator:

    >     [..somelist..]   [..someprog..]   infra

    > will temporarily take ..somelist.. to become the stack, execute

    > ..someprog.. to yield a different stack, and finally push  that

    > as a list onto the previous stack:

    >     10  11  12  [13 14]  [dup dup]  infra    ==

    >     10  11  12  [13 13 13 14]

    > This happens at run time, of course. In the discussion there

    > seemed to be a demand for doing this at compilee time, so that

    > the declaration

    >     mylist  ==  !! [13 14]  [dup dup]  infra !!

    > would be the same as

    >     mylist  ==  [13 13 14]

    > because the !! part was executed at compile time (when storing

    > the definition).

    >     It would be possible to add such a feature, essentially making

    > Joy its own macro expansion language. The early IBM language PL1

    > did that sort of thing.

     It would be redundant. Joy can treat programs as data and therefore it

    can be its own macro expansion language already; this is because

    computation can be done at compile time if an expression is static (ie.

    does not involve any unknown inputs). Notice that your example is

    static, since infra requires two inputs which are both supplied.

    The only benefit of !! would be that the compiler does not need to do

    binding time analysis (figure out which bits of the program are static)

    thus making it simpler. However, it is very tedious for a programmer to

    identify and maintain the static/dynamic boundary to the same extent

    that BTA can.

     > But I remain to be convinced about the usefulness of such a facility.

    > I prefer not to add more and more features and make Joy bloated for the

    > sake of making it bigger.

     I fully agree.

    --

    Louis.