[RPL/2] Please explain this behaviour

Adrian Blake adrian.blake at ieee.org
Dim 16 Déc 22:44:10 CET 2007


I should explain a little more about what I would like to do.

I would like to have a sub-program that is altered by the main program and then that sub-program is re-compiled or evaluated. My 
though was to take lists which contain the sub-program, alter those then re-compile. The lists would be long and contain other lists.

One approach would be to create a main program that edit a text file/s that are the sub-programs, then use system calls to execute 
then sub-programs.

Any suggestions welcome.

Adrian

BERTRAND Joël wrote:
> DEMAINE Benoit-Pierre wrote:
>> Adrian Blake wrote:
>>> RPL/2> clear
>>> RPL/2> { 2 3 + } list-> drop eval
>>>
>>> as expected, good
>> Yes.
> 
> 	Yes, but it is a side effect (and very strange, but I have verified
> this afternoon on my 28S and my 48SX, and I can obtain the same result).
> There is no reason to put in stack a function.
> 
>>> RPL/2> { 3 4 * } list-> drop eval
>>>
>>> also as expected, good
>> yes.
> 
> 	Same remark.
> 
>>> RPL/2> { 2 3 { 3 4 * } + + } list-> drop eval
>>> +++Error : Invalid argument type for << { 2 3 { 3 4 * } + + } list-> drop eval >> command
>>> result should be 17
>> No. You are wrong, the error is right.
> 
> 	Yes, isn't it ? ;-)
> 
>>> or should it be this
>>> { 2 3 { 3 4 * } list-> drop eval + + } list-> drop eval
>>>
>>> no ..fails
>>>
>>> So what is the correct syntax?
>> A list is not a program.
>>
>> It may work if you wrote
>> << 2 3 { 3 4 * } + + >>
> 
> 	Your expression cannot be evaluated because you try to add an integer
> (3) and a list ({ 3 4 * }). You can write:
> 
> 	<< 2 3 { 3 4 * } list-> drop eval + + >>
> 
> but I don't understand why you don't use
> 
> 	<< 2 3 << 3 4 * >> eval + + >>
> 
> Any explanations ?
> 
>> because this way, you put things in stack, and evaluate them one after
>> the other.
>>
>> But, perform steps one by one, by hand in CLI, put the list, then
>> execute list->, and you will see that after DROP, the first 2 elements
>> of the stack are the last two objets of the list, twice a plus.
>>
>> Since a plus takes as argument "two values", givving this command as
>> argument a command can not work: you can not add the plus sign to a
>> value. You can only add '+' to an array.
>>
>> In the best case, you could hope to EVAL
>>
>> 3: { 3
>>      4
>>      * }
>> 2: +
>> 1: +
> 
> 	If you try to evaluate this one, RPL/2 gives you an error. You have to
> write { 3 4 * } { + } + to obtain { 3 4 * + }. '+' requires two lists as
> arguments in this case.
> 
>> and get
>>
>> 1: { 3
>>      4
>>      *
>>      + }
>>
>> Thats would make sense to me. But, in any case, you can NOT hope getting
>> a number as result to this.
>>
>> Bcause when you arrive at the EVAL step, the stack has at the bottom two
>> '+' operators.
>>
>> It's not a syntax problem, but a design problem (or, YOU not
>> understanding the RPL objects).
>>
>> RPL is somehow commutative. But, not the way you think.
>>
>> { 2 3 { 3 4 * } + + } list-> drop eval
>> has NO WAY to ever work.
>>
>> Any way, type just
>> 2 3 { 3 4 * } + +
>> and you will also get an error.
>>
>> I dont really guess what you intend to do; I can not see your point, or
>> guess how any modification of your example could lead to anything
>> interesting.
>>
>> Before posting the ML, please, try manually your commands. If you had type
>> { 2 3 { 3 4 * } + + } list-> drop eval
>> manually step by step, you would have seen the problem immediately:
>> evaluating:
>> 3: { 3
>>      4
>>      * }
>> 2: +
>> 1: +
>> CAN NOT lead to what you had in mind, what ever it was.
>>
>> Did you ever use HP calculators ? Maybe you should read some RPL
>> tutorial on the web if there is any; maybe on http://www.hpcalc.org/ You
>> are having a very basic problem, generic to RPL, not specific to the
>> implementation by Bertrand. Your thing should faile the same way on HP
>> machines (I just would have expecte the result to be a list containing
>> '+' in the end).
>>
> 
> 	Regards,
> 
> 	JKB
> _______________________________________________
> RPL2 mailing list
> RPL2 at rayleigh.systella.fr
> https://www.systella.fr/cgi-bin/mailman/listinfo/rpl2
> http://www.systella.fr/~bertrand/rpl2/english.html
> 
> 

-- 
Adrian Blake
Molonglo Radio Observatory
University of Sydney
1152 Hoskinstown Rd
Bungendore 2621
ph. 02 62382262  mobile 0407 232 978

http://150.101.125.30/images


Plus d'informations sur la liste de diffusion RPL2