yksom, as opposed to most other SOMs, currently doesn't require class names to match their file names, which can lead to weird behaviours where loading new classes overwrites existing globals which makes previously loaded classes unreachable.
Consider the two following classes:
" Defined in `Foo.som` "
Foo = (
sayHello = (
'I am the real Foo' println.
)
)
" Defined in `Bar.som` "
Foo = (
sayHello = (
'I am the imposter Foo' println.
)
)
Now, consider the following Main class:
" Defined in `Main.som` "
Main = (
run: args = (
Foo new sayHello.
Bar new sayHello.
Foo new sayHello.
Bar new sayHello.
)
)
Executing Main results in the following surprising output:
I am the real Foo
I am the imposter Foo
I am the imposter Foo
I am the imposter Foo
Due to the conflicting naming, it seems that loading the class from Bar.som did overwrite the #Bar global but also the already existing #Foo global, which seems undesirable.
yksom, as opposed to most other SOMs, currently doesn't require class names to match their file names, which can lead to weird behaviours where loading new classes overwrites existing globals which makes previously loaded classes unreachable.
Consider the two following classes:
Now, consider the following
Mainclass:Executing
Mainresults in the following surprising output:Due to the conflicting naming, it seems that loading the class from
Bar.somdid overwrite the#Barglobal but also the already existing#Fooglobal, which seems undesirable.