Archived messages from: gitter.im/red/red.js from year: 2022

GaryMiller
20:17@ALANVF any news on red.js?

ALANVF
00:26@GaryMiller I'm still working on it on-and-off (also balancing with my work on Star), however I'm currently in search for a new job as... things happened and I dropped college, and was not accepted to work at Replit again, so I will probably be less active on both projects for a little while
GaryMiller
01:09Sorry to hear about the job situation. Obviously that takes first priority. Best of luck in the job search!
ALANVF
01:23thanks :thumbsup:

ALANVF
20:44ok so thinking about an implementation issue
20:44how does context? work?
GiuseppeChillemi
20:44What are you asking?
ALANVF
20:45I was under the impression that words only store the context they came from, not the object that the context belongs it
20:45this is why func[/local a][context? 'a] will return the function itself
20:46but how/where is the function stored? is it stored with the context or the word?
GiuseppeChillemi
20:46Words have values in a context. They point to a context where you have both the symbol and the value.
ALANVF
20:47sure, but say that word a belongs to context b, which is associated with object c. does a store a reference to b and c, or does b store a reference to c (as well as c storing a reference to b)?
20:48hopefully that makes sense
20:49maybe this is better asked in red/red
GiuseppeChillemi
20:50a does store a reference to an anonymous context.
ALANVF
GiuseppeChillemi
20:50b value is a reference to that anonyous context
ALANVF
20:50but does it also store a reference to the actual object the context belongs to, or does the context do that?
GiuseppeChillemi
20:51it = ?
ALANVF
GiuseppeChillemi
20:52Wait a minute, I need to search something
ALANVF
20:52I see this in the runtime code:
red-context!: alias struct! [
	header 	[integer!]								;-- cell header
	symbols	[node!]									;-- array of symbol IDs
	values	[node!]									;-- block of values (do not move this field!)
	self	[node!]									;-- indirect auto-reference (optimization)
]

maybe self is the reference to the object, or the context (being a cyclic reference)?
GiuseppeChillemi
20:53I can't answer this question, @hiiamboris or @greggirwin will
20:57From my archive, from my master: @9414
20:57https://gitter.im/red/help?at=5e7f658459057617f049a7ee
hiiamboris
20:58what's the question
ALANVF
20:58> sure, but say that word a belongs to context b, which is associated with object c. does a store a reference to b and c, or does b store a reference to c (as well as c storing a reference to b)?
hiiamboris
20:59what's "associated"?
20:59ah, I see what you mean
ALANVF
20:59yeah, objects store a reference to their context
GiuseppeChillemi
21:00@ALANVF https://gitter.im/red/help?at=5c345c64357dd7655d354ab3
21:00From Nenad
ALANVF
21:01ok so that supports what I've already thought about, so does that mean that contexts store a reference to their associated object/function?
hiiamboris
21:01a should store a reference to context b, not object c (context can be a function too)
ALANVF
21:01sure, that's what I'm doing currently
21:02but somehow, context? is able to access c
21:02I am thinking about this from an implementation standpoint
21:03or perhaps this can be thought of in an object-oriented way where objects and functions both have context as a base class?, meaning objects/functions are types of contexts?
21:04that doesn't seem to hold up when looking at the impl details though
GiuseppeChillemi
21:06@ALANVF Here is what I was searching for: https://gitter.im/red/help?at=5accc5a91130fe3d36c0b7e9
ALANVF
21:08hmm ok so it does appear that b does contain a reference to c, that's helpful thanks!
21:09this can however probably be modeled using the object-oriented approach I discussed earlier though
GiuseppeChillemi
21:10Another link:
https://gitter.im/red/help?at=5dc6a5feeeb63e1a838156b4
21:10It is the last one until you will request me to continue
ALANVF
21:11no that's plenty helpful, thanks :+1:
hiiamboris
21:26Red runtime is a damn maze
ALANVF
21:26lol yeah kinda
hiiamboris
21:27my version is: ctx/node refers to a hashtable, and first value in that hash table contains the initial object/function (or maybe even 2nd value)
ALANVF
21:27yeah that lines up with my conclusion from earlier
21:28I'm now rewriting some of the red.js code to follow this
hiiamboris
21:28:+1:
ALANVF
21:30fun fact: while looking into this, I found that the global object context has an id of -1
hiiamboris
21:37https://github.com/red/red/blob/38b42610d2ddd5af53f0133dfe81d9391785126e/runtime/datatypes/context.reds#L404
not a hashtable, just 2-cell series
21:37https://github.com/red/red/blob/38b42610d2ddd5af53f0133dfe81d9391785126e/runtime/datatypes/object.reds#L912
second value is the object/func
ALANVF
21:37yeah that's what I figured, thanks
21:38a lot of R/S code is a bit cryptic for me because of all the pointer arithmetic lol
hiiamboris
21:39yeah it's like navigating a network of teleports without a map :)
21:41not so much the pointers, but how things depend on other things
21:41View is even more of a mess, esp. it's Draw part
GiuseppeChillemi
21:51OMG, I am loosing the hope to learn the inner working of RED!
ALANVF
22:09ok got it working
22:09[![image.png](https://files.gitter.im/5ec064b3d73408ce4fe3fbdb/BHtp/thumb/image.png)](https://files.gitter.im/5ec064b3d73408ce4fe3fbdb/BHtp/image.png)

ALANVF
23:02ohhhh I just figured out how symbols work
23:02apparently words refer to symbols, and are not actually the same thing
23:03that makes a lot more sense

ALANVF
19:59got words and contexts/objects working correctly
19:59[![image.png](https://files.gitter.im/5ec064b3d73408ce4fe3fbdb/CKwQ/thumb/image.png)](https://files.gitter.im/5ec064b3d73408ce4fe3fbdb/CKwQ/image.png)
GiuseppeChillemi
20:03Nice!
greggirwin
20:27:+1:

ALANVF
01:24finally figured out how to correctly implement self
01:24[![image.png](https://files.gitter.im/5ec064b3d73408ce4fe3fbdb/2e7o/thumb/image.png)](https://files.gitter.im/5ec064b3d73408ce4fe3fbdb/2e7o/image.png)
01:24that was a headache
01:27I personally don't like how self is configured in Red after spending a few hours trying to figure it out, and I think there's probably a better way to do it in the future

ALANVF
02:10ok so thought
02:10https://github.com/red/red/blob/master/runtime/datatypes/float.reds#L669 is a pita to implement in js without tons of extra allocations because you cannot simply get the binary repr of a float
02:11so uh, do I go with an expensive algorithm to do it with less allocations, use the bad solution, or do something else? (and if so, what?)
22:44the compare action is now available for many more datatypes, including numbers and words
22:44many basic series actions are also now available

toomasv
03:23:+1:
greggirwin
17:13@ALANVF on floats, the first thing I would do is the easy thing, i.e. what JS does naturally with numbers. Then find the cases where that differs from Red and document it. There should be tests for Red to help focus on where that's used. With that, it can be put on a list and prioritized against other features.
ALANVF
19:50@greggirwin yep that's what I've done for now. I think that worst-case scenario, I could use an external JS library that does something similar and determine (and document) how that differs from Red's behavior

ALANVF
20:39Red.js has now been updated to Haxe 4.3 preview since it's now stable
20:40(curious, it's not showing up in the activity log?)

GaryMiller
00:35Did 4.3 have any features you've been waiting for? Still making any headway otherwise?
ALANVF
00:354.3 added null-safety features (like ?? and ?. operators), and it fixed a lot of compiler bugs
00:36it should be less annoying to work on new features now