« first day (1852 days earlier)      last day (1928 days later) » 

1:30 AM
>> do append [equal?] map-each target [{a b} {[a b]}] [load target]
 
; Brought to you by: try.rebol.nl
== true
 
Two questions:
1) Is that the way you would write that?
2) Do you think that this equality should be in the core test suite?
Question 1 is partly because I am wondering if map-onto, which I define as func [x y z][map-each y z x], reads better.
The other parts of question 1 are, can it be done without the do, and is it better to map than to duplicate for a case like this.
 
1:55 AM
What, no answer already? What kind of lame forum is this? :)
That is just to emphasize I want as many people as possible to chime in on this one ...
And, of course, that I am willing to wait. Which may mean I'm not using chat particularly properly :) :)
But neither question really seems worthy of SO Q&A to me.
 
2:17 AM
>> map-each target [{a b} {[a b]}] [load target]
 
; Brought to you by: try.rebol.nl
== [[a b] [a b]]
 
@MarkI Without broader context I'd probably write that as (load {a b}) = (load {[a b]}), and be very unlikely to prepend things with a prefix operator whatever I was trying to achieve...just because it's hard to read.
 
 
1 hour later…
3:23 AM
Thanks HF. I know it's a very subjective topic.
In this particular case I was trying to keep the two "targets" adjacent, for direct visual comparison purposes.
Your way is good, and may even be better, I'm still thinking about it.
If load were replaced by to-block to-paren load to-string to-tag or the like, maybe they would be too far apart.
 
@MarkI You could keep them adjacent and compose. every [x y] [{a b} {[a b]}] [do compose [equal? load (x) load (y)]]
 
Yep. That indeed may read better than my append angle on it.
Still has the long-identical-functional-expression-duplicating problem though.
But aside from creating a temp function, I'm not sure there's a good way out of that, or even that there should be one.
Actually your solution has pointed me to a do-free way!
>> foreach [x y] [{a b} {[a b]}] [equal? load x load y]
 
3:39 AM
; Brought to you by: try.rebol.nl
== true
 
I like this best of all (of the duplicating versions) so far.
Ooh! I improved it already!
>> foreach [testf x y] [load {a b} {[a b]}] [equal? apply get testf [x] apply get testf [y]]
 
; Brought to you by: try.rebol.nl
== true
 
There's still an ugly part unfortunately, needs more work ...
Why can't I just say testf x? Why do I have to write apply get and wrap the x?
 
@MarkI foreach [testf x y] [load {a b} {[a b]}] [equal? (eval :testf x) (eval :testf y)]
>> foreach [testf x y] [load {a b} {[a b]}] [equal? (do :testf x) (do :testf y)]
 
; Brought to you by: try.rebol.nl
== false
 
3:51 AM
>> foreach [testf x y] reduce [:load {a b} {[a b]}] [equal? (do :testf x) (do :testf y)]
 
; Brought to you by: try.rebol.nl
== true
 
>> foreach [testf x y] reduce [:load {a b} {[a b]}] [equal? do :testf x do :testf y]
 
>> foreach [:testf x y] reduce [load {a b} {[a b]}] [equal? (do :testf x) (do :testf y)]
 
; Brought to you by: try.rebol.nl
== true
; Brought to you by: try.rebol.nl
; rebol.com/r3/docs/errors/script-invalid-arg.html
    *** ERROR
** Script error: invalid argument: :testf
** Where: foreach
** Near: foreach [:testf x y] reduce [load "a b" "[a b]"] [equal? (do...
 
Jinx!
 
3:52 AM
Well, there's an expansion. If you use a get-word in the slot, it gets.
That would be useful.
 
Yep. I don't like that this cool version uses not one but three "do"s. Okay, two "do"s and a "reduce".
 
Well the feature is stricken from do for good reasons, but eval will be frameless and very fast
So it's one of those things you will consider cheap-as-free
 
Got it down to just the reduce.
>> foreach [testf x y] reduce [:load {a b} {[a b]}] [equal? testf x testf y]
 
; Brought to you by: try.rebol.nl
== true
 
Well the best of all worlds here would be every [:testf x y] [load {a b} {[a b]}] [equal? testf x testf y]
 
3:57 AM
Now it would be totally done if we had your get-word expansion style
Jinx again!
 
Still can't stand the "word" "foreach".
 
Indeed. Sorry about that.
Hm. I think the colon should be on the target, not on the word.
So in (every) foreach, if what you're binding to the word is a get-word or a get-path, then get it.
Because if what you wanted was actually the get-thing, you just to a non get-thing.
If that even makes any sense ...
 
@MarkI A foreach is over arbitrary data, I think mutations should be in the spec of the iterator not warping the data.
 
Basically what I'm saying is [f x y][:load "a" "b"] instead of [:f x y][load "a" "b"]
So the get will stop you from reading the (real) function as active. But it's a small point in any case.
 
The tough thing being that when used not in a block, a get goes through the soft quote used by foreach to get the word (or block, or whatever) to use.
So if you wanted the behavior in a single case, you'd have to say foreach [:x] [append reduce] [...] instead of foreach :x [append reduce] [...] which isn't necessarily a bad thing.
y: [:x]
foreach :y [append reduce] [...]
 
4:10 AM
>> foreach [f1 x y] [load {a b} {[a b]}] [f2: get f1 equal? f2 x f2 y]
 
; Brought to you by: try.rebol.nl
== true
 
Dumb temporaries, but it works, and is relatively clean. Top candidate ATM.
There's a get, but that is not nearly as bad as a do or a reduce.
 
If you don't actually need the foreach, this is what wrap was for
But then, again, as first said, you would just say load. Need a larger code sample.
Must sleep, but hope to make more headway on the grand unification of frameless-and-frames. Had to solve the problem of frameless natives not being in the stack trace, causing me to think deeper about it and I've probably got it...just not going to finish tonight.
 
Of course! That's hilarious.
>> set [f x y] [load {a b} {[a b]}] f: get f equal? f x f y
 
Happy Day of Bird Murder.
 
4:16 AM
; Brought to you by: try.rebol.nl
== true
 
@HostileFork Keep up the awesomeness HF!
@HostileFork And that's really a fowl murder.
 
 
6 hours later…
10:00 AM
@HostileFork You can also look at it as a cooperation. The turkey is a successfull species because humans like eating them.
 
 
5 hours later…
3:02 PM
I have bad news and good news. Which do you want to hear first?
The bad news is, the rabid performance enhancements I was looking at may not be as ludicrously fast as I planned...
...the good news is, the adaptations involved may bring us to the break even point where we can eliminate the function vs. closure distinction, with all functions acting with the (better) closure semantics, at no performance loss vs. today's Rebol.
(Which to me, is actually more interesting than being broken and flawed but faster...I would say one of the great victories of definitional returns and the design was to suffer no loss in performance yet get the long-sought feature.)
So this is my current goal, to twist the redesign to dovetail the performance enhancements in some areas with some adjustments in others to eliminate CLOSURE (or eliminate FUNCTION and rename CLOSURE to FUNCTION. However you want to look at it)
I could do some hacks here and there and keep function on life support and go in the performance-enhancement direction and keep that train of thought going... I'm just reluctant to go on that path, vs. the opportunity I'm seeing now, to just kill it
(e.g. something shinier caught my attention, and I'm now feeling pulled to the shinier thing than just making the status quo stupid fast)
And to be clear, when I said "not as fast as I planned" doesn't mean I couldn't do that direction, I meant I may be spending the performance points on something systemically purifying that costs those points vs. just leaving them leftover for user code to burn.
@MarkI ^-- Assuming you agree with this prioritization, the elimination of function vs. closure with full closure semantics at same speed vs. faster but having to worry about it? You can always speed up the correct thing...but often can't correct the fast broken thing. :-/
 
3:37 PM
Stack-relative contexts (that is, function! contexts) are not broken HF. They are different. What about them do you insist is broken?
From Graham's excellent comparison page:
Although the stack indirection slows down [function!] word references around 28%, it speeds up function calls and makes recursion and multitasking easier.
When called, a closure repeats most of the overhead of creating the closure in the first place, so you should generally use functions instead unless you need to use the closure’s words after it returns.
A closure pays a very heavy price on invocation: [it] must bind its entire body and all sub-blocks before it evaluates.
A closure also generates a lot more garbage than a function (for which it is possible, in R3, to create no garbage).
 
@MarkI Nothing good about it. Broken. Pass a word bound to that function you get the last invocation, which is well likely unrelated at all to any intent.
 
Don't do that then. You're not supposed to.
 
That is the basic premise of the entire system.
 
What? You are only supposed to access function words during execution of the function.
 
It's a garbage collected language.
 
3:40 PM
Closures are what you use if you want to violate that restriction.
 
Things should stay live as long as they're referenced. You don't introduce a highly broken manual memory management system into such a language, where not only do the references go bad if you're not on the stack, they can pick up completely unrelated values from incidental invocations of the same function.
The only reason to do so is if you're up against a wall on performance you cannot solve, and I'm removing that wall.
if I can equalize and/or beat current performance, already better than rebolsource, and eliminate the distinction...that is a victory worth wiping the distinction off the map.
In looking at it, I have a pretty good toolkit for thinking I might be able to do exactly that, though I have to run numbers to see if that is actual fact, after I write it.
As far as actually wiping out the body copies, I've had a few ideas about wedging some kind of "viewer" field into series values... I freed up that third platform word in the ANY-SERIES! cells and have been trying to think of a good use for it.
If a REBVAL had a series, index, and viewer and you picked a WORD out of it, then the binding of the word could be mapped through the viewer during the pick, with some intense modifications.
I'm not sure, though, if the code complexity and savings is really that much better than investing in a superior amortized GC
 
So you are trying to design some sort of (clunction? flosure?) beast that will act like a closure but be as fast and garbage-free as a function? I will be glad to give you mucho kudos if you can do that!
Graham's article has provided you with the tests, even.
It isn't even the speed that is critical, really it's the slowness of all those contexts being garbage collected that is the major evilness of closures.
And making GC faster won't help with that.
Well, not significantly anyway.
 
4:06 PM
@MarkI I said that, I could speed the system overall, and during that speedup when I hit barriers to preserving existing mechanisms vs. finding a way to eliminate the dichotomy, my leaning would be to spend my speedup points on eliminating the distinction.
So if I made an overall system that was cleaner and faster than current that didn't have to worry about the distinction I call that "level up" and don't sit and fret about how much faster it could have been if I preserved it and went the other way.
At the cost of user confusion, (core) code complexity, etc. etc.
I said if.
If we had just one type of clunction/flosure then we could focus our efforts on its character, and its needs, systemically.
 
4:21 PM
Absolutely, but I believe the result of this being hashed out in a CureCode war was that garbage-freeness and permanent-binding are theoretically and practically impossible to have together. Hence, the two Rebol function types, one for each desire.
 
@MarkI I don't believe the desire for brokenness is a legitimate desire. If you want to call out to a high-performance language for some function via a FFI or something then do so, don't break the layer.
If there's going to be a distinction between Rebol/Ren-C/Do (or whatever we call this) and Red coming, it's going to be one is correct while the other doesn't care about that.
 
@HostileFork We are going to have to agree to disagree whether garbage-freeness is a broken idea or not.
 
@MarkI Well, do you want a malloc in Rebol?
 
?
 
With the "function" model you are introducing a time-based, broken, reuse of pointers system.
 
4:24 PM
And that has to do with malloc because ...
 
Maybe the pointer is bad, maybe it got reused.
Because that's how malloc works. Maybe your pointer goes bad, maybe you waited long enough and something else happened and the pointer is good again with data you didn't intend.
 
And maybe you shouldn't be accessing it ...
 
And maybe that's just not in the Quality of the concerns that the layer provision of the artifact being designed should concern you with.
 
Sorry HF, I am not following. malloc'd pointers go bad?
 
After they're freed, sure.
But another malloc can reclaim them, and so someone holding on to that pointer might get new data. Might not. Depends.
 
4:26 PM
Then don't use them after they're freed?
 
How do you know if they're free?
 
You freed them.
Or leaving the function frees them.
 
foo: func [x] [bar [x]]
Systemically speaking, if you don't know what bar does, and you don't know what it did with that bound argument, how is bar to know if x will be freed out from under it?
You passed it series, those stay good as long as it holds them.
 
As long is bar is running, foo is on the stack and x is accessible.
 
Bar might have put that into an object.
It might be collect-like, it might store the data somewhere and then get off the stack.
 
4:29 PM
Use a closure then?
 
I don't want to have to think about this. I'm using a language that is not manually memory managed.
If I wanted to worry about this stuff, I'd use something else.
That something else would have tools like smart pointers/etc. to help me
There is no legitimate reason to want the broken behavior.
You put up with the broken behavior because of a belief that closures are too slow.
Well, guess what... interpreters are slow also. If you're not looking for the benefits of the choices you've chosen, you're in the wrong toolspace.
 
@HostileFork No. Because garbage-freeness is a valuable attribute on its own, even if garbage collection were instantaneous.
 
Nonsense.
 
I see what you are saying about dangling refs though.
 
GC does not solve resource control problems, and this is one of the reasons why RAII in C++ is important... what good is it to leave a bunch of dangling resources to something that is dead and say "it's still there! You won't... crash..." when semantically believing it's still there is as bad as a crash if not worse.
 
4:33 PM
@HostileFork You lose debating points with that statement, just saying.
 
I said the only non-nonsensical version of your statement.
Resource Acquisition Is Initialization (RAII) is a programming idiom used in several object-oriented languages, most prominently C++, where it originated, but also D, Ada, Vala, and Rust. The technique was developed for exception-safe resource management in C++ during 1984–89, primarily by Bjarne Stroustrup and Andrew Koenig, and the term itself was coined by Stroustrup. RAII is generally pronounced as an initialism, sometimes pronounced as "R, A, double I". In RAII, holding a resource is tied to object lifetime: resource allocation (acquisition) is done during object creation (specifically...
IF you wish to introduce a concept of a nullable resource in Rebol, the right form for that is not the function closure distinction.
And, it would have to go null... not dangle and be reuptaken, but go null and stay null for as long as a ref existed to ask for it.
 
In Racket, if you unbind a word it walks through memory and removes occurrences of that word. I wouldn't want that.
But apparently anything that doesn't do that is "broken".
 
Well, you can unset the variable to which something is set, that seems reasonable enough to me. Protect it if you're paranoid and don't want someone else setting it.
 
"If a feature can be misused, it is broken." Well, I disagree.
 
If you want your locals unset when you terminate, that might not be a terrible thing to offer a feature for.
But that is different.
But I don't think that's a feature of FUNC or CLOS, that would be some little trailer code in FUNCTION.
Then wipe out CLOS and save us headaches.
 
4:39 PM
I'm going to lay odds you'd rather Rebol was unable to build circular blocks either.
Because, that would make some functions infinite loop, so it must be "broken".
 
I don't know if I have an opinion on that, though I have a kind of interesting data structure for O(1) prohibitions of insertions of cycles into directed graphs: nocycle.hostilefork.com
 
Cool. I did something similar once, long ago.
 
The logo, also, clever. :-)
I called the structure an "adjacency spiral"
 
@HostileFork You would still have the accesses-a-different-invocations-value problem. That one doesn't go away until you use a closure.
 
@MarkI Yes, I believe I stated that there would not be a distinction.
I'm not opposed to an option on function which is a kind of <isolate>
Which would put that tail on the closure-behaving FUNC it writes.
 
4:46 PM
posted on November 26, 2015 by Oldes

Before this fix: red>> make pair! [2.1 3.456] *** MAKE Error: pair expects a block with two integers == -858993459x1408749273 red>> make pair! 1.2 *** Runtime Error 1: access violation *** at: 0041A6ECh With this fix: red>> make pair! [2.1 3.456] *** Syntax error: invalid construction spec: 2.1 3.456 *** Where: make red>> make pair! 1.2 *** Script error: 1.2 type

 
I do not think the word "closure" in the canon ever conveyed what it is in Rebol as a shade of distinction, and I do not think the failures of function are ever desirable unless you think the system can't ramp up and give you decent performance without the hack.
But I sort of feel this "unset when finished" suggests something perhaps even more fine-grained, a kind of desire to introduce scope, and kill things automatically when they are "out of scope", which seems to me to be per-variable (and that a function boundary isn't the necessarily interesting scope in question).
Do I miss C++ smart pointers and other things in Rebol (and, hack, ANSI C89, which is basically assembly as far as I care)? Sure I miss them.
 
Bottom line: Garbage collection is never free, and therefore I think garbage-freeness will always be a desirable attribute.
Do I want to pay the price if that price is a potential crash? I don't know.
 
Okay, well, why don't we just do like Red and have an escaping into a kind of inline systems language?
 
I am having trouble breathing for some reason.
 
Bear in mind, I used to be a big fan of the Red plan, made sense to me. Still does.
 
4:50 PM
Makes me gag.
Has its merits I'll admit. They're just not for me.
 
Nothing wrong with being able to bridge as long as you don't compromise the world for the people who would like to live in a "purer" world.
But every level has its own "purity"
Even PHP. Because pure garbage is still, in some sense, a kind of pure.
I think I decided that I don't know that #[()] is good for unset, and might prefer another symbol. #[?] perhaps.
It's hard because I almost want to give #[] to unset vs. none. But #[?] doesn't make sense for none, and looks good for unset.
#[+] true, #[-] false, #[?] unset, #[] none
It's only the last that I feel is a bit semiotically lacking because I kind of feel it has equal claim with unset there.
Incidentally, big props go to @Brett for the integration of source analysis into test.
Now there's a C parser written in Rebol, that's not part of bootstrap, used to audit for source characteristics... formatting, usage of functions you're not supposed to call from certain files, etc.
Lines that are more than 79 columns, etc. :-)
But whatever test one might wish to splice in there, one can, and get a report. We've got a lot of long lines still, but that will all get cleaned up now that he's also added multi-line prototype parsing.
 
 
4 hours later…
8:41 PM
@HostileFork, please please please, I really need your help! I need to call Apply_Func_Throws in Mold_value (s-mold.c), but I must backup BUF_MOLD and MOLD_LOOP before the call, and restore them after. Which is the right way to do this? (PS: You-Are-Awesome :-)
 
@giuliolunati You don't have to say the you're awesome thing first unless you're going to attack work I'm doing without pitching in any help! :-)
You don't have to worry about it, @Brett doesn't have to worry about it, @rgchris doesn't have to worry about it, etc. etc. It's some of those other people. :-)
 
@giuliolunati Well you remember what I suggested about having a kind of "mold stack"? I think that is a good idea. We already have the data stack and such. I've run into trouble myself with some routines that wish to be optimized, where it seems that what's really needed is a unicode-character-based kind of data stack, that can have series copied out...
@giuliolunati So imagine something a bit like Pop_Stack_Values: github.com/metaeducation/ren-c/blob/…
e.g. there is a string buffer hanging around, per "thread" (or instance, whatever you want to think of that as), and this string buffer can be pushed to where all you have to do is remember the point when you started... and all recursions are required to come back to a balanced state when they return, even if they use the same service.
Then when you're ready, you just pop-into a series like that, and that series may be a new one. With strings you have the added question of if you're going to consolidate that down to a byte string or a unicode wide string, once you've seen all the characters and if they'd fit in a byte string or not.
Going forward, Rebol should support even wider than 2-byte unicode, if the string has such characters in it (likely uncommon)
@GrahamChiu doesn't have to say it, he works hard enough helping the world already
@giuliolunati Given that I already want it, why don't we switch the mold buffer to work in the way described. The mold buffer is then (for now) a REBUNI-wide per-task string. When you begin a mold state you mark where the mold buffer tail is at that point in time (it may not be the start). Then you keep appending onto it. If someone you call starts a new mold state, they too mark where the tail was, and promise to put it back at the end to the same tail.
Then when you finish mold, it grabs out the string into a precisely sized new series that is either byte-size or rebuni-size depending. Perhaps the mold state could track the largest character width it saw added.
So very much like Pop_Stack_Values getting the data stack into a new series, but with a string.
 
@HostileFork we need also take care of MOLD_LOOP
 
8:56 PM
@giuliolunati I'm not as immersed in mold as you may be. What is MOLD_LOOP for?
 
@HostileFork keeps track of what we are molding, to avoid recursion
 
9:16 PM
@giuliolunati If recursion were safe--with a mark on where you started and each mold bringing it back to that mark--why would you need it?
 
@HostileFork it's a Carl thing... if a block contains a reference to itself, molding can loop forever...
 
@giuliolunati Ah, okay, well sure, then that should be accounted for too...though it's a good point about "moldability" in general. I had a hope that at least for any x you could say x = (load mold x), where you might not have the bindings right but the structure/symbols would be okay. I had not considered the impact of loops on that.
I believe that if you copy a looped structure you get a stack overflow at the moment
 
@HostileFork consider x: reduce [:add] load mold x ...
 
@giuliolunati Reloading a native and getting something that will compare as equal? is not hard to imagine, but if generalized functions always compare by identity then that would be a problem as well yes.
We are already generally a bit troubled in the idea that you can take something in, and then convert it to a string, and then load it back without loss by things like comments and formatting.
So it will never happen, but I don't think that means one shouldn't seek to offer "some kind of molding guarantee"
What is this guarantee like? I do not know. But I think there should be one.
 
@HostileFork Back to mold-stack: I like that thing, but seems very hard to rewrite entirely s-mold.c
 
9:40 PM
@giuliolunati Modify with confidence is the goal, so if it's hard it needs to be made not hard. :-)
It should be fluid to change and try out ideas and change them back if need be.
That is what good code is like.
 
@HostileFork ATM s-mold.c seems very hard to modify... maybe we must rewrite it entirely :-(
@HostileFork working on it I understood your modify-with-confidence goal :-)
 
@giuliolunati Well I've been messing with this code for a while now, and you did start by saying "help", and this is a much easier request than "solve objects". I'm in the middle of something right now. Is your main concern about "saving off to the side and then restoring" performance?
 
No, main concern is something not crashing ;-(
I don't understand enough gc and how protect things from it and how avoid leaks .... :-(
My 1st approach with memcpy was very rude
@HostileFork main obstacle on mold-stack road seems Reset_Mold
 
9:58 PM
@giuliolunati You can guard a series from GC with PUSH_GUARD_SERIES, and there is also PUSH_GUARD_VALUE if you have a REBVAL that may have series to protect. The asserts should warn you if you make a mistake to DROP_GUARD on them.
If you Make_Series or Make_Array you are responsible for either MANAGE_SERIES on it (to hand it over to the GC) or Free_Series (if you do not need it to be handed to GC). If there is an error that happens that takes away your control, any unmanaged series that were around will be freed automatically.
You do not need to guard a series from GC if it has not been made "managed", it will not be freed out from under you because the GC does not see it.
@giuliolunati You can do malloc's but if you do, you will need to trap longjmps caused by fails. These fails could be from memory errors even in Make_Series type primitives. For a good example, see how the malloc internally to Zlib is handled with PUSH_UNHALTABLE_TRAP
 
@HostileFork Ooh, thanks! So basically I can do Make_Series, copy things to, then restore them from and do Free_Series ?
 
@giuliolunati Yes, you should be safe from GC and also the leaks on errors should be handled automatically. See: Trapped_Helper_Halted which is used by PUSH_TRAP
 
Seems good enough for now. You saved my day :-)
 
@giuliolunati :-) Well always feel free to ask questions, even if I cannot make an instant decision on the objects!
 
@HostileFork the more I work on code the more I understand we need think and rethink before decide.
 
10:11 PM
@giuliolunati Amen!
 
;-)
(Maybe God also had thinked and re-thinked before code down the world...)
 
10:25 PM
@giuliolunati Hopefully he will have your realization and rethink some more! :-/
 

« first day (1852 days earlier)      last day (1928 days later) »