Skip to content

compilation of dssl2 interfaces does not work right, due to use of gensym #38

Description

@rfindler

The program below, when run without a .zo file, runs fine, but when it is first compiled to a .zo file (e.g. via raco make x.rkt or similar) then it produces an error saying that the class ListQueue does not implement the queue interface.

I believe the issue is due to this use of gensym. It looks like this gensym is transmitted around during macro expansion to various places and eventually put into the output of a macro and used as the identity of an interface. Unfortunately, when a file is compiled to bytecode, the identities of these gensyms won't be preserved.

I believe the right strategy is to bind a runtime value (that provides the identity) and then to refer to that identifier whenever the identity is needed, comparing that at runtime with eq?.

#lang dssl2
import ring_buffer 

class ListQueue[T] (QUEUE):
    let _head
    let _tail

    def __init__ (self):
        self._head = None
        self._tail = None
    
    def enqueue(self, element: T) -> NoneC:
       1 

    def dequeue(self) -> T:
       2

    def empty?(self) -> bool?:
        return self._head == None 

def fill_playlist (q: QUEUE!): 
    1

fill_playlist(ListQueue())

Thanks to @mflatt for identifying the problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions