Lists, Tables, Psets
Tue, 28 Mar 2000 19:28:51 -0500
> > > In general, it is most natural for parameters to be used in the
> > > reverse order that they were pushed.
> > Yes, but who is to say that is the same "natural" order to push those
> > values onto the stack to make a function call?
> I am; it is most natural to push first the things that will be used
> last. But, this is just an observation about Joy; I'm not saying it
> applies to other kinds of systems...
But as the caller how do I know what order the function use the
> Hmm... In the current Joy system, one does not define the interface
> for programs, but only defines the programs themselves. There is room
> for improvement in this area, I think; it would be nice
> if the system allowed one to specify certain "interface" properties
> of programs (which were checked by the system to ensure that they
> really did have those properties), for instance the types of things
> they expect and leave on the stack, and whether the program is pure
> (without side effects) or not.
Once you have structures to describe the interface to a function your
size benefit might be gone.
> > I worry about the complexity of the logic required to
> > optimize code for a fixed register machine. We can modularize the
> > process for optimization:
> > Joy Code -> Logical Intent -> Machine Code
> > I am saying that the "Logical Intent" is the right representation.
> Hmm... Joy code is itself very nice to reason about; I don't think
> there's a need to use an intermediate format.
If I was to make a compiler, for fixed register processor, then I would
HAVE to go convert Joy functions to the intermediate format to
understand intent and make efficient code. Somewhere, sometime, I will
have to represent "Name is the first parameter" before I can go making
the machine code to manipulate it.
> 2 3 Add_Integer 4 5 Add_Integer Multiply_Integer
> It surely seems cleaner to me not having those "(", "=", ")", ",", ";"'s
> cluttering things ...
You say clutter, I say loss of intent.
> No... You just have to remember the Order... this is not really much
> worse than having to remember the names "Name", "Age", and "Spouse",
> except that those names have English significance that help one
In DBOS (uses psets), the mapping from field name to field must be done
in the head. Joy requires the a mapping from element to field AND the
order of the elements. Consider the question "what is the 9th letter of
the alphabet?" You have the mapping from glyphs-to-letters stored in
your head, but you store the order of the alphabet separately; having to
follow the "linked list in your head until you get to the 9th letter.
If you manage to remember the absolute position of every parameter then
you are maintaining a map from digit to position, and then to field in
your head. The same number of maps, but different arrangement.
I have seen the common mistake:
"Kyle", 26, "Rhonda", MyFunction
"Rhonda", 26, "Kyle", MyFunction
Both valid, in terms of interface, but one has the wrong result.
Kyle Lahnakoski Arcavia Software Ltd.
(416) 892-7784 http://www.arcavia.com