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

Invalid primitives #27

Open
ltratt opened this issue Mar 9, 2020 · 4 comments
Open

Invalid primitives #27

ltratt opened this issue Mar 9, 2020 · 4 comments
Labels
spec Needs specification, or is specification related.

Comments

@ltratt
Copy link

ltratt commented Mar 9, 2020

At least in Java SOM, calling an unknown primitive causes a warning to be printed, but execution to continue -- which, to me, feels surprising! Should it not immediately cause a fatal error?

$ cat test.som
class_load = (
    madeup = primitive

    run = (
        1 println.
        self madeup.
        2 println.
    )
)
$ zsh som.sh -cp Smalltalk test.som
Primitives class som.primitives.testPrimitives not found
1
Warning: undefined primitive madeup called
2
@smarr
Copy link
Member

smarr commented Mar 9, 2020

Why is this surprising?
It's a dynamic language, if the primitive is never activated, there's no problem.

There is also the practical reason of implementing a language completely: you want the warning, but you don't want to be blocked by irrelevant bits.

@smarr
Copy link
Member

smarr commented Mar 9, 2020

But, it's inconsistent among different SOMs.

CSOM errors. SOM and SOM++ give warnings.

@ltratt
Copy link
Author

ltratt commented Mar 9, 2020

Note there are two warnings in the example I gave: a compile-time warning and a run-time warning. I can see an argument for the compile-time warning being a warning (though I think it should be an error) but I can't see any real argument for the run-time warning being a warning (turning it into a no-op seems the worst of all worlds to me!).

@smarr
Copy link
Member

smarr commented Mar 9, 2020

Sorry, didn't read correctly.

Looking at the code: "this has always been like this" as far as I can tell.
https://github.com/SOM-st/som-java/blame/7a7c94d1a9e08c80ed01b65e55aeacc5ddf60559/src/som/vmobjects/Primitive.java#L88-L92

But yes, not ideal.
The empty primitive should probably send #error: to self with that message instead.

@smarr smarr added the spec Needs specification, or is specification related. label Mar 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
spec Needs specification, or is specification related.
Projects
None yet
Development

No branches or pull requests

2 participants