From: SourceForge.net <no...@so...> - 2005-08-31 14:45:14
|
Bugs item #1222927, was opened at 2005-06-17 15:54 Message generated for change (Comment added) made by robert_dodier You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=1222927&group_id=4933 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Lisp Core Group: Fix for 5.9.2 >Status: Closed >Resolution: Wont Fix Priority: 5 Submitted By: van_Nek (van_nek) Assigned to: Nobody/Anonymous (nobody) Summary: scope for a variable in buildq? Initial Comment: (%i1) printlist(list)::=buildq([temp:ev(list)],print(splice(temp)))$ (%i2) list:[1,2,3]$ (%i3) printlist(list); SPLICE(TEMP) returned LIST But SPLICE must return a list #0: printlist(list=LIST) -- an error. Quitting. To debug this try DEBUGMODE(TRUE); (%i4) ref:list$ (%i5) printlist(ref); 1 2 3 (%o5) 3 this is confusing! (%i12) f(x):=x**2$ (%i13) x:3$ (%i14) f(x); (%o14) 9 that works! Am I not allowed to use any name for a variable in buildq? van_Nek va...@gm... ---------------------------------------------------------------------- >Comment By: Robert Dodier (robert_dodier) Date: 2005-08-31 08:45 Message: Logged In: YES user_id=501686 As stated below, the phenomenon observed here is a consequence of the rules of binding and evaluation. So I am closing this report as a non-bug. ---------------------------------------------------------------------- Comment By: van_Nek (van_nek) Date: 2005-06-21 10:10 Message: Logged In: YES user_id=1269745 Dear Robert Dodier, thanks for your answer. I am not really happy with the work of SPLICE in BUILDQ, but you showed, that with the use of APPLY there is a much easier way. Volker van Nek ---------------------------------------------------------------------- Comment By: Robert Dodier (robert_dodier) Date: 2005-06-18 20:24 Message: Logged In: YES user_id=501686 The problem is that before expanding printlist, the formal argument list is bound to the actual argument, also named list. Given that, ev (list) => list (not the actual [1, 2, 3]) and then splice complains. Same complaint if the formal and actual arguments have the same name (something other than "list"), e.g., FOO. This is strange, although I'm not sure if it can be considered a bug, as it is a straightforward consequence of the general rules for binding and evaluation. In any event, maybe apply (print, list) has the effect you want? How about: printlist (list) := apply (print, list); list: [1,2,3]; printlist (list); 1 2 3 3 ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=1222927&group_id=4933 |