Giter Site home page Giter Site logo

Comments (6)

nuggreat avatar nuggreat commented on August 13, 2024

What version of kOS are you on because this {set time to "Time for coffee".} and this {set constant to lex("pi", 3.5).} should be throwing a compile time errors.

from kos.

numberlesstim avatar numberlesstim commented on August 13, 2024

I'm running v1.4.0.0

from kos.

numberlesstim avatar numberlesstim commented on August 13, 2024

I just realized i had config:clobberbuiltins set to true, so with that off the two points you mentioned no longer hold. The rest still applies though.

from kos.

nuggreat avatar nuggreat commented on August 13, 2024

Good to know I had to ask after the version because we have had a few people who have for one reason or another been on older versions without knowing it and updating fixed the issue.

I was able to reproduce the error on my end though my test cases ended up looking like this:

log "" to "foo.ks".
run foo. { global x is 1. print defined(x). } print defined(x).

and

//used the foo.ks from above
run foo. {print defined(time).} print defined(time).

and

log "global y is 2." to "bar.ks".
run bar. { print defined(y). } print defined(y).

In my tests the log was only run once and restarts occurred between attempts to remove the added global vars.
Both cases ended up printing

false
true

when they should be printing

true
true

I also tested running the tests as files and not commands typed into the terminal and got the expected result.
At a guess this is down to the terminal execution environment is in a strange state after run command and not fully settled until you have a prompt again.

from kos.

numberlesstim avatar numberlesstim commented on August 13, 2024

Actually even with clobberbuiltins enabled this

run foo. {set time to "Time for coffee".}
print time.

should still not print Time for coffee but rather some TIMESTAMP(...), meaning in this setup it does not clobber locally but rather overrides globally.
So it does behave fundamentally different than without running a program first like

{set time to "Time for tea".}
print time.

which prints TIMESTAMP(...) as expected.

from kos.

nuggreat avatar nuggreat commented on August 13, 2024

the abnormal behavior in this case

{set time to "Time for tea".}
print time.

is that it prints TIMESTAMP(...) as the set should be clobbering time in the global scope as without a LOCAL TIME TO ... the SET defaults global.

Which some what counterintuitively means that means that

run foo. {set time to "Time for coffee".}
print time.

is behaving correctly and the other case does not. But as both cases involve clobbering built ins the behavior will always be rather abnormal as it was never intended that you could clobber built ins hence the default setting to prevent it.

from kos.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.