hide local variables from substitution for a user defined object
Subject: hide local variables from substitution for a user defined object
From: Sergey Litvinov
Date: Fri, 29 Nov 2013 14:55:54 +0100
Robert Dodier <robert.dodier at gmail.com> writes:
> Well, I dunno if this is the best way, but it is a way.
> You can try 'blex' (lexical block) which is implemented by the
> attached code. It is pretty simple-minded but maybe useful.
Thanks. I am trying to use it and have some questions.
This part is OK.
(%i1) load ("./blex.lisp") $
(%i2) e1 : blex ([i], my_sum (i, [i]))$
(%i3) e2 : blex ([i], my_sum (j*i, [i]))$
(%i4) at(e2, i=42);
(%o4) my_sum(j i, [i])
(%i5) at(e2, j=42);
(%o5) my_sum(42 i, [i])
(%i6) freeof(i, e2);
(%o6) true
(%i7) freeof(j, e2);
(%o7) false
How to work with local variables? My attempt fails.
(%i8) is(inpart(e1, 1)=i);
(%o8) false
(%i9) is(part(e1, 1)=i);
(%o9) false
It would be nice to respect `listdummyvars'. Currently,
(%i11) block([listdummyvars: false], listofvars(e1));
(%o11) [i]
(%i12) block([listdummyvars: true], listofvars(e1));
(%o12) [i]
How to impliment this function?
(%i10) substdummy(j, i, e1);
(%o10) my_sum(j, [j])