Open berekuk opened 1 year ago
Quick comments:
Another option might be to call it, @debug()
or @logger()
or similar. (For rendering a value to the sidebar)
A similar way of doing this would be to have "log" statements that rendered to the view. No extra syntax needed. Just,
log(normal(5,2))
.
This would be really useful for debugging.
Having some Console.logRunningTime(str) would also be useful, for debugging how much time steps take.
log(normal(5,2))
This is problematic syntax-wise; usual Squiggle statements are assignments, but this one isn't (previously: call
keyword, void
type, etc.)
Even if we remove top-level end expressions, we still have end expression in blocks.
We have inspect, I was imagining that log() could work like that. It could return the variable.
I guess it could be a norm to do:
_ = logger("foo", var10)
_ = logger("foo", var10)
Two reasons I don't like this approach:
_ = ...
relies on variable shadowing for _
(assuming it's a variable and not special syntax), and I hope we'll remove variable shadowing eventuallylogger
has a side-effect, so it's not pure anymore, but the interpreter won't be aware of that; this means that we won't be able to do optimizations such as parallel evaluation (which I expect to become very important later on, and I don't want to create a precedent here)
This is an early draft of an idea that we discussed, that I want to write down in some form.
What are we missing compared to Jupyter-style notebooks to render Squiggle to the nice list of interspersed values and markdown notes?
We already have:
Example emulating a notebook in Squiggle 0.8.4: https://www.squiggle-language.com/playground#code=eNqrVkpJTUsszSlxzk9JVbJSqlCwVTCNyasEUkYKJfkgdkxedEyegkKMkkdqUap6sUKFVYySDkikQgci7piXopABkauEyVXG5MUq1QIAV4ocbg%3D%3D
Still, it doesn't feel as nice as Jupyter or Observable notebooks.
Key reasons:
Also, sometimes you might want to render a plot and in 90%+ cases you won't be interested in storing the plot object to the variable. In that case, coming up with a variable name is also annoying.
This makes me think that in addition to
variables
andresult
, we need to add a third mode; something generate a notebook output (array of interspersed values) from the code. Some of those values won't be bound to any variables, but the reducer would collect all values and all bindings in the right order and return those as a "notebook" object.Previous related discussions: #977, #720.
Previously we discussed ideas such as
value -> ignore
orcall
keyword.call
(or mayberender
; see my https://github.com/quantified-uncertainty/squiggle/issues/977#issuecomment-1266901523) is still possible, but for markdown specifically we'd either need some syntax with braces, or multiline strings.Syntax ideas: