Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not properly copying empty blocks inside object methods #1839

Open
drkameleon opened this issue Dec 18, 2024 · 0 comments
Open

Not properly copying empty blocks inside object methods #1839

drkameleon opened this issue Dec 18, 2024 · 0 comments
Assignees
Labels
:block bug Something isn't working critical Critical, top-priority issues :object oop Type definitions & object-oriented aspects of Arturo

Comments

@drkameleon
Copy link
Collaborator

Describe the bug

define :queue [
    init: method [][
        this\items: []            <----- INITIAL ASSIGNMENT
    ]

    enqueue: method [item][
        panic "enqueue must be implemented by concrete type"
    ]

    dequeue: method [][
        panic "dequeue must be implemented by concrete type" 
    ]
]

define :simpleQueue is :queue [
    enqueue: method [item][       
        'this\items ++ item       <----- THIS ALTERS `[]` ITSELF !!!!!
        print "ENQUEUE"
        print size []             <----- THIS IS NOT AN EMPTY BLOCK ANYMORE
        inspect []
    ]

    dequeue: method [][           <----- NOT EVEN THAT IS AN EMPTY BLOCK?!
        if empty? this\items -> return null
        pop 'this\items
    ]

]

; Usage example
q: to :simpleQueue []!
inspect q
inspect to :bytecode [
    q\enqueue "first"
]
q\enqueue "first"
q\enqueue "second"

inspect to :bytecode [
    q\dequeue       ; first
]
q\dequeue
q\dequeue       ; second
q\dequeue       ; null
@drkameleon drkameleon added bug Something isn't working critical Critical, top-priority issues oop Type definitions & object-oriented aspects of Arturo :block :object labels Dec 18, 2024
@drkameleon drkameleon self-assigned this Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:block bug Something isn't working critical Critical, top-priority issues :object oop Type definitions & object-oriented aspects of Arturo
Projects
None yet
Development

No branches or pull requests

1 participant