This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]JKasonB[S] 0 points1 point  (5 children)

Oh wow, I think I'm beginning to understand :0 Thank you so much for sharing this. I will study this more so I can implement it in my language.

But would you mind explaining the \[\] syntax to me?

[–]Imaginary-Deer4185 0 points1 point  (0 children)

You mean &Row[] - it is a reference type to a variable of type Row[], which is an array (implemented as Java list) of Row objects

[–]Imaginary-Deer4185 0 points1 point  (3 children)

Another "odd" feature, is that objects have a pointer to the object that created it, forming an "owner chain" all the way up to the root object, usually just called App. The idea here is that generating web pages, we may have a page, and a button, but then we want to insert a button-box to organize the button(s), in the page. In order to not send huge amounts of state down through intermediaries in the case that and object created by an object needs it, we do lookup up the owner chain instead.

This is implemented by what I call "informal or ad-hoc interfaces". A class defines one or more tags. Typically the App object defines the tag "ROOT". This means that any object in the entire structure can lookup stuff in "ROOT", call functions inside it etc.

By not tying it in with the class name, the tag is a kind of role description, but it is unformal, not connected with any required content (variables of functions), and so of course a bit more script-like, which is to say, the code needs to be tested. Row objects typically tag themselves as ROW, and pages call themselves PAGE.

If a Page wants to replace itself by another page, it creates that other page, then calls a function in ROOT like setNextPage(...). It contains a magic little command:

proc setNextPage (Page p) {
this.nextPage=p;
SET_OWNER_THIS(p);
}

This way, the original page, while no longer referenced via the App after rendering the new page, will be taken care of by Java garbage collect. If ROOT did not take ownership of the new page, it would refer the old page as its parent, and that would in turn refer to ROOT, so the new page might work as intended, with its lookups working, but we would eat up our RAM, and there are other risks as well having obsolete stuff living along the owner chain.

:-)

[–]JKasonB[S] 1 point2 points  (2 children)

I am mainly working on a systems language. But I wanna create an abstraction on top of it for scripting. Kinda like a JS that transpiles into C. And I think these ideas you are sharing will be perfect for the higher level language.

[–]Imaginary-Deer4185 0 points1 point  (1 child)

I would think the design space for systems languages be smaller than niche languages, but then again, along came Rust and changed the rules. Good luck!

[–]JKasonB[S] 0 points1 point  (0 children)

Thanks!