How to crash Julia 1.0.1 REPL

Base.getproperty(::DataType, s::Symbol) = "crash"

Also if you define e.g.

Base.:+(x::Int, y::Int) = x - y

This is just expected if you mess with internals.

2 Likes

That is why I posted it here instead of opening an issue. Sometimes the cure is worse than the disease.

Patient: “If I push here it hurts.”
Doctor: “Well, then don’t do that.”

Question: is it worth fixing?

4 Likes

But it is more like, you misuse a tool to hurt youself, though, namely, you cut yourself with a knife instead of chopping veggies.

There has been some discussion of “freezing” some functions to prevent new methods being added to them that override core functionality, such as integer addition.

I have a dream…that one day Julia will be completely self-hosted (or, well, at least that Julia’s implementation will consist solely of Julia + LLVM). “Freezing” core functionality like this is a sure way to ensure that this reality could never be achieved. For an example of a language that has moved from a C + “stuff” implementation to a pure self-hosted solution, and reaped rewards for doing so: Go. For an example of a language that has un-override-able core functions (and is, unsurprisingly, not available self-hosted): Javascript.

1 Like

The example that @jandehaan posted is akin to modifying GCC to change an if statement to behave like a while statement. The only difference here is that in Julia, it’s much easier to make drastic changes with a very, very small amount of code.

I’m in agreement with the argument that this is just misuse of a tool/feature; that said, maybe having the ability to opt-in to freezing certain core functionality could be useful, especially for beginners (with a suitable warning when they actually try to redefine something important so they learn to not try that in the future). The only issue with this, as @jballanc alludes to, is that certain more advanced (and frankly, very cool) functionality, like Cassette’s overdubbing, could potentially become unusable.

Thankfully, this is Julia, not JavaScript, and if we ever started to head in the terrible direction of intentionally and permanently handicapping the language, then there’d be plenty of people (myself included) fighting against that.