• Join/Login
  • Business Software
  • Open Source Software
  • For Vendors
  • Blog
  • About
  • More
    • Articles
    • Create
    • SourceForge Podcast
    • Site Documentation
    • Subscribe to our Newsletter
    • Support Request
SourceForge logo
For Vendors Help Create Join Login
SourceForge logo
Business Software
Open Source Software
SourceForge Podcast
Resources
  • Articles
  • Case Studies
  • Blog
Menu
  • Help
  • Create
  • Join
  • Login
  • Home
  • Browse
  • FMSLogo
  • Bugs
FMSLogo

QUEUE and DEQUEUE don't work with some variable names

A Logo programming environment for Microsoft Windows

Brought to you by: david_costanzo
  • Summary
  • Files
  • Reviews
  • Support
  • Tickets ▾
    • Feature Requests
    • Bugs
    • Support Requests
  • Discussion
  • Code
Menu ▾ ▴
  • Create Ticket
  • View Stats

Group

  • v_6.06x
  • v_6.07.X
  • v_6.08.X
  • v_6.10.X
  • v_6.11.X
  • v_6.13.X
  • v_6.22.X
  • v_6.25.X
  • v_6.26.X
  • v_6.27.X
  • v_6.28.X
  • v_6.29.X

Searches

  • Changes
  • Closed Tickets
  • Open Tickets

Help

  • Formatting Help

#598 QUEUE and DEQUEUE don't work with some variable names

v_6.06x
closed-fixed
nobody
None
5
2026-04-04
2025-01-30
Vilim
No
> 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 "make (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.

Related

Bugs: #597
Bugs: #599

Discussion

  • Vilim

    Vilim - 2025-01-30
     

    Last edit: Vilim 2025-01-30
    If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
  • David Costanzo

    David Costanzo - 2025-01-31
    • status: open --> open-accepted
     
    If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
  • David Costanzo

    David Costanzo - 2025-01-31

    Good bug! "queue is a reasonable name for a queue, so it should work. Your first proposed solution is similar to what UCBLogo does: make the parameter names less likely to shadow the queue name.

    I like your approach with the macro because it would make QUEUE/DEQUEUE work regardless of the queue's name. You code looks correct, so I agree that there's probably some deeper bug that prevents it from working.

     
    If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
  • David Costanzo

    David Costanzo - 2025-02-03

    I opened Bug #599 to cover the bug in .MACRO that prevents DEQUEUE from being written as a macro.

     

    Related

    Bugs: #599

    If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
  • David Costanzo

    David Costanzo - 2025-06-08

    There's a similar problem in NAME, except that its parameter names were selected to be unlikely to shadow a programmer's names. If QUEUE/DEQUEUE is rewritten to be a marco, it makes sense that NAME should also be rewritten.

    to name :name.value.input :name.variable.input
    make :name.variable.input :name.value.input
    end
    
     
    If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
  • David Costanzo

    David Costanzo - 2025-12-01

    I have updated QUEUE and DEQUEUE to use the same parameter names used in UCBLogo in [r6112]. This does not fix the bug, but it mitigates the bug by making a conflict less likely. It also makes it so that a logo program that works in UCBLogo won't fail in FMSLogo and vice-versa. Even less likely parameter names could have been chosen, such as ones that include a space in their name, but I think there's value in have the same bug as UCBLogo until the bug is fixed.

    I had hoped to fix this completely, but it looks unlikely that I'll fix the macro bug that prevents a complete fix before the next release of FMSLogo and I wanted to enable queues named "queue" in the next release (even if queues name "the.queue.name" now won't work).

     

    Related

    Commit: [r6112]


    Last edit: David Costanzo 2026-03-30
    If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
  • David Costanzo

    David Costanzo - 2026-03-30
    • status: open-accepted --> closed-fixed
     
    If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
  • David Costanzo

    David Costanzo - 2026-03-30

    I fixed the macro bug, which enabled me to use Vilim's suggestion of converting QUEUE and DEQUEUE into macros to avoid the naming conflict. This is implemented in [r6130]. It will be available in FMSLogo 8.5.0.

    When I used pure macros as Vilim provided, the procedures became much slower. I worked out a hybrid solution, similar in spirit to what the .MACRO documentation recommends. The general macros are only used when there's a naming conflict. Otherwise, the code looks a lot like it did before.

    My performance test:

    To PerfTest
      Local [q before]
    
      Make "before TimeMilli
      Repeat 100 [ Make "q [] Repeat 1000 [ Queue "q RepCount ] ]
      Print (Sentence [Total Queue Time] TimeMilli - :before [ms])
    
      Make "before TimeMilli
      Repeat 100 [ Make "q [1 2 3 4 5 6 7 8 9 10] Repeat 10 [ Ignore Dequeue "q ] ]
      Print (Sentence [Total Dequeue Time] TimeMilli - :before [ms])
    End
    

    As functions (the way FMSLogo used to do it)

    Total Queue Time 1641 ms
    Total Dequeue Time 13 ms
    

    As simple macros

    Total Queue Time 6355 ms
    Total Dequeue Time 74 ms
    

    As macros that do something simpler when there's no name conflict:

    Total Queue Time 1753 ms
    Total Dequeue Time 15 ms
    

    This is still a little slower, even when people don't have conflicting queue names, but it's the cost of having procedures that work in every case. This makes me wonder if Brian Harvey knew about the bug and chose not to fix it for performance reasons.

     

    Related

    Bugs: #599
    Commit: [r6130]

    If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
    • Vilim

      Vilim - 2026-03-30

      I spotted an interesting idiom in the new dequeue implementation! Is [first [x]] the most efficient way to construct a value that evaluates to x when fed into run regardless of the type of x? Better than using quoted?

       
      If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
      • David Costanzo

        David Costanzo - 2026-04-02

        Vilim asks

        Is [first [x]] the most efficient way to construct a value that evaluates to x when fed into run regardless of the type of x? Better than using quoted?

        By my measurements, yes, it's faster. The outer list is necessary, so the difference is really between (FIRST (LIST :x)) and (QUOTED :x). Since FIRST and LIST are primitives, they're faster.

        Here's an updated PerfTest that's more sensitive to DEQUEUE's performance. It uses non-words in the queue so that QUOTED does less computation.

        To PerfTest
          Local [q original before]
        
          Make "before TimeMilli
          Repeat 100 [ Make "q [] Repeat 1000 [ Queue "q RepCount ] ]
          Print (Sentence [Total Queue Time] TimeMilli - :before [ms])
        
          Make "original []
          Repeat 100 [ Queue "original [] ]
        
          Make "before TimeMilli
          Repeat 1000 [ Make "q :original Repeat 100 [ Ignore Dequeue "q ] ]
          Print (Sentence [Total Dequeue Time] TimeMilli - :before [ms])
        End
        

        I ran the new PerfTest with the what I had committed in [r6130].

        Total Queue Time 1383 ms
        Total Dequeue Time 964 ms
        

        Then I changed the last line of DEQUEUE to use QUOTED as:

          output (list quoted :the.item.value)
        

        and got execution times like:

        Total Queue Time 1389 ms
        Total Dequeue Time 1234 ms
        

        That said, I'm open to suggestions. I can attach a pre-release executable that has the macro bug fixed if you want to experiment yourself.

         

        Related

        Commit: [r6130]


        Last edit: David Costanzo 2026-04-04
        If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
        • Vilim

          Vilim - 2026-04-02

          If quoted was a primitive, it could just call maybe_quote...
          If backtick was a primitive, making performant macros would be so much easier...

           
          If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
          • David Costanzo

            David Costanzo - 2026-04-04

            Vilim writes:

            If quoted was a primitive, it could just call maybe_quote...
            If backtick was a primitive, making performant macros would be so much easier...

            Both those statements are true. Similarly, I could have fixed this bug by making QUEUE and DEQUEUE primitives instead of macros. However, I try to avoid adding new primitives due to the compatibility risk. Any existing program which defines a procedure with the same name as the new primitive won't run on the new FMSLogo. This is a small risk, but I prefer no risk to a small risk.

            The main reason I was concerned about performance of the new QUEUE and DEQUEUE is not because I wanted the procedures to run faster but because I didn't want them to run significantly slower than before. Performance degradation is also a compatibility risk.

             
            If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
  • David Costanzo

    David Costanzo - 2026-04-04

    [r6141] fixes NAME using a similar strategy that I used for QUEUE and DEQUEUE. This will also be available in FMSLogo 8.5.0.

     

    Related

    Commit: [r6141]

    If you would like to refer to this comment somewhere else in this project, copy and paste the following link:

Log in to post a comment.

SourceForge
  • Create a Project
  • Open Source Software
  • Business Software
  • Top Downloaded Projects
Company
  • About
  • Team
  • SourceForge Headquarters
    1320 Columbia Street Suite 310
    San Diego, CA 92101
    +1 (858) 422-6466
Resources
  • Support
  • Site Documentation
  • Site Status
  • SourceForge Reviews
SourceForge logo
© 2026 Slashdot Media. All Rights Reserved.
Terms Privacy Opt Out Advertise
mdb logo