I'd like to point out one feature of Matlab(TM): if its usual end of line semicolon ; is omitted, the result of the statement is displayed on the console.
Can you show me an online example or URL of a documentation or explanation?
I haven't tried it yet but somebody told me that there is a way to put #p in front of a clojure form for a similar effect
I am thinking of a YS language extension. Whenever in YS there is a colon : one could write repl: so that the expression is printed. And then one has a file-watch-mode which only watches those expressions with repl: in them...
Can you expand on that thought with a small example?
I can write a blog post where I explain; but I am sure when you write this idea to REPL people they will agree that this covers 80% of a REPL experience. Plus: YS would be a language where people (for the first time?) could write about how they use their REPL daily. Because at the time being it is so hard to understand what REPL means, but with this it would be immediately clear.
I'm just not certain what you mean syntactically with your idea
ah, ok, mom
Instead of
say:
+: 1 2
one could write
+ repl: 1 2
and get the same output 3but one could also write
say:
+ repl: 1 2
and get twice the number 3 on the consoleThat's one way for sure. I can think of a couple others and also different contexts.
I'll retort after I finish doing the dishes
but in file-watch-mode, one would at initial run see twice the number 3 on the console but YS would not terminate but watch for changes in the file. And if the file is changed, only expressions with repl: in them would be evaluated. So for example if one changes the 1 to 4 and save the file, one would only see 6 once on screen.
The Matlab idea is described under the "Use of Semicolon (;) in MATLAB" header at URL https://www.tutorialspoint.com/matlab/matlab_syntax.htm
Here's my quick ideas on this:
!yamlscript/v0
defn fn1(a b):
c =:
+: a b
=>: c * 3
defn fn2(a b):
c =:
repl:
+: a b
=>: c * 3
defn fn3(a b):
c =: !repl:
+: a b
=>: c * 3
defn fn4(a b):
c =: !repl:
+: a b
=>: (c * 3).repl()• fn1 is an example fn
• we want to avoid doing fn2 style as it requires indentation (but it would work fine)
• I thought I already implemented "tag function calls" in YS but maybe it's on a branch? I can't find it. The idea is that YAML tags consisting of a symbol word and ending with a : compile to a function call using the node as an argument...
• Chaining functions calls on yes expressions work anywhere. You'll want this to work with both mapping pair calls and yes-expr calls.
the !foo: is really powerful. I was sure I implemented it but maybe not...
it's also usable to call functions in data mode without switching modes first
the foo repl: bar doesn't work out quite as well hygenically
I can explain more later on, but I have to go afk now
I'll figure out what the status !foo: is. Perplexed on that
I think the driving use case was merging maps in data mode:
blah: !
merge:
=>: *map1
=>: !
key1: val1
can be:
blah: !merge:
- *map1
- key1: val1We don't see tags in YAML usage much.
In YS so far we see !yamlscript/v0 and ! so far
I think tags can play a big part in YS, used judiciously
one thing I've wanted for some time is !clj for specifying a pur clojure node...
YS syntax is not yet set up to write Clojure macros (with macro syntax forms) very well yet
ok out of time 🙂 thanks for the repl/debugging ideas. We'll make it slick
The !foo: case is exactly what I was looking for. But I did not get it to work. But certainly nowhere near urgent. It is just that the Matlab people love this semicolon trick. One guy stated this feature as a reason not to use Python. So I thought I bring it up. Thank you for the quick response.
The www function is a fine invention indeed! On the Matlab example, in addition to your observation that it prints value+context, I'd like to point out Matlab's Ctrl+E , which triggers execution of the file. In effect they have a Repl-feel with this (feel only, because it does read file from disk, run, stop -- no Repl-real with its omnipresent internal state). And I think this Repl-feel is part of Matlab success. Now I also think one hurdle to wider adoption of Repl-real is its need for nrepl connection of the Editor. Notepad++ users, hence scripting-people (not developers), do not have a chance to taste the Repl-feel. But we have in Clojure a tradition started by Bruce Hauman -- it is Figwheel hot reload. He realised that thinking in terms of "file on disk" has its appeal and the wide adoption of hot-reload I think proves him right. Thus, before implementing nrepl, a file watcher in YAMLScript would be, I think, a step to at least consider.
All of that is going to take me some time to digest. Might need to discuss it point by point with you...
Hammock time, discuss with other people as well, is very necessary
www is from https://metacpan.org/pod/XXX which I always port to any language I use 🙂
It's one of my constant debugging tools for writing the code for ys
right now I'm using it to debug my ys and clj versions of https://rosettacode.org/wiki/Weird_numbers 😄
The coding of which has led me to at least 3 things I want to make ys better
This XXX-YYY-ZZZ driven development should become the idiomatic way for every YS disciple. I just saw it for the first time, but it rings a bell. Do you use nrepl-connection for the Word_numbers implementation, or do you use the brisk startup time and run-file-from-disk?
both
mostly nrepl
I just realized the matlab semicolon thing is more than I thought
for their example
x = 3;
y = x + 5
it prints:
y = 8not just 8...
That's pretty cool
I was just thinking of having a function that printed the node value, or sent it to the repl
but if it could also show the context of where that value came from
btw there is a std www function that prints a value to stderr then returns the value:
$ cat foo.ys
!yamlscript/v0/
a:
b:
- c
- !
www: 2 ** 10
- d
$ ys -Y foo.ys
---
1024.0
...
a:
b:
- c
- 1024.0
- d
(it wraps output with --- and ... lines)