« first day (3626 days earlier)      last day (154 days later) » 

6:28 AM
posted on October 04, 2020 by @hostilefork Brian Dickens

@hostilefork wrote: I've talked about the idea of using TUPLE! for "predicates". The specific concept that I had would be that the elements of the tuple would represent the function calls in the order you'd write them: >> any .even? [1 3 7 10 13] ; parallel to `even? 1`, `even? 3`... == 10 >> all .not.odd? [2 4 6 8] ; parallel to `not od

 
 
9 hours later…
3:26 PM
‌>> source void
void: make action! [ [
‌    {Function returning void result (alternative for `#[void]`)}
‌    return: [void!]
‌][
‌    return: make action! [
‌        ["Returns a value from an action" value [<opt> <end> any-value!]]
‌        [unwind/with (binding of 'return) either end? 'value [] [:value]]
‌    ] ()
‌    void
‌] ]
What's with the redefinition of return?
If I write voidd: make action! [ [ return: [void!] ][ '#[void] ] ] it seems to work fine ...
 
3:38 PM
@MarkI All RETURNs work this way, they are functions created at the time of instantiation that bind to the specific instance of the function. That's a projected view of an optimized implementation that doesn't actually run through an action manufacture, but it's how you would have to do it yourself if writing a similar feature.
The concept was that return: was just a way of defining a local variable; the lower-level way of doing so (vs. using the "higher level" <local> which could just turn the following words into SET-WORD!)
These ideas are shuffling a bit, as I think I want to take SET-WORD!: in specs for adding multiple return values.
And have that work with AUGMENT so you can add a return value after-the-fact.
The () is the function body fed in, groupified...which was empty. The void at the end is the "fallout" from the original definition saying return: <void>. Again, this is all projected...the actual implementation uses a "voider dispatcher" which optimizedly sets the result to void, it's just trying to give you a picture of what it would look like in source.
 
 
1 hour later…
4:52 PM
posted on October 04, 2020 by @hostilefork Brian Dickens

@hostilefork wrote: With Generic Tuple, the dawn of NewPath is upon us. >> file: 'base/sub/name.ext >> first file == base ; word! >> third file == name.ext ; tuple! >> last third file == ext ; word! I'm trying to think about good sanity-checking features that will pay dividends, like this one: >> extension: "txt" &

 
5:45 PM
@HostileForksaysdonttrustSE Your answers raise questions (as usual haha): (1) doesn't () always vanish? (2) as written it looks infinitely recursive, if I "did it myself" that way would it work at all? (3) what is the difference in functionality between the way it is and what I wrote? (4) if return is "just" a local variable, could it be fred?
 
@MarkI (1) yes, because as group! [] for the "isolated" body execution inline produced that. It's filling in a slot in a template, and arguably that slot could disappear entirely, but it would mean more code. (2) MAKE ACTION! doesn't do the magic; if you used FUNC to build return then it would be infinitely recursive. (3) nothing different for this case, no. (4): yes
Your example doesn't have "RETURN" in the return-sense, so it's doing nothing. It's just an unused local. There is no RETURN ACTION!.
RETURN in its definitional form is a specific outcome of using a generator that makes it.
e.g. there is no "return keyword". This is all in the magick of what definitional returns accomplished.
But FUNC is optimized to do it in a very lightweight fashion, that would be bulkier if you built FUNC in usermode but would have the same outcome.
I'm eyeing Go's feature of letting you set named return values at arbitrary points in the function...which you can do with multiple returns but not the "main return". So there may be some new thinking coming related to that.
Also, RETURN becoming variadic, so if you say return 1 2 then that assigns the returns in order. But again, letting you assign at arbitrary points...meaning that RETURN alone doesn't necessarily mean "return void" but just "leave the return value at whatever I set it to, and void if I didn't set it to anything"
Something Go and Rust and the Google-style-guide-prohibiting-exceptions-in-C++ all have in common is that the programming world has soured on the idea of being able to meaningfully capture arbitrary thrown failures from random points in your code at higher levels.
Everyone is switching to that as a discouraged last resort, and instead making error handling part of the multi-return contract of a function...and if you ask for and handle that multi return, a "likely-non-recoverable-error" occurs, probably a panic.
Bending toward this direction is likely wise, e.g. far less TRAP (old "TRY/EXCEPT") or ATTEMPT. You speak to the error of the routine you just immediately called. If you don't handle it or bubble it up explicitly, you accept a kind of failure that is unlikely to be recovered at higher levels.
 

« first day (3626 days earlier)      last day (154 days later) »