QUEUE and DEQUEUE don't work with some variable names
A Logo programming environment for Microsoft Windows
Brought to you by:
david_costanzo
> make "queue []
> queue "queue "item
< lput doesn't like queue as input in queue
> make "item []
> queue "item "abc
< lput doesn't like abc as input in queue
Proposed solution: edit queue.lgo and deque.lgo in logolib:
to queue :logolib.queue.queue :logolib.queue.item
make :logolib.queue.queue lput :logolib.queue.item thing :logolib.queue.queue
end
to dequeue :logolib.dequeue.queue
local "result
make "result first thing :logolib.dequeue.queue
make :logolib.dequeue.queue butfirst thing :logolib.dequeue.queue
output :result
end
I also attempted a more robust solution using macros:
.macro queue :queue :item
op (list "testmake (word "" :queue) "lput (quoted :item) "thing (word "" :queue))
end
.macro dequeue :queue
op (list "invoke (list "make (word "" :queue) "butfirst "thing (word "" :queue) "?) "first "thing (word "" :queue))
end
While this works for QUEUE, DEQUEUE seems to still execute its output instructionlist within its own context, but only when used as an argument to a procedure:
> make "queue [abc]
> show dequeue "queue
< q
> show :queue
< [abc]
> dequeue "queue
< You don't say what to do with abc in invoke
< [.maybeoutput apply :function :inputs]
> show :queue
< []
I assume this is a bug in the FMSLogo core.
While testing I once even encountered a strange behavior where the template (where the MAKE call is) was executed in the outer context even though the arguments to INVOKE were evaluated in the inner context:
> make "queue [abc]
> show dequeue "queue
< q
> show :queue
< []
But I couldn't reproduce it again.
Closing as a duplicate of Bug #598.
Related
Bugs:
#598