gingerBill
Also, how is Cling what I want? "Cling is an interactive C++ interpreter..." and "...uses just-in-time (JIT) compiler for compilation." This seems like the exact opposite to what I want.
1 2 3 4 5 6 | struct Entity{ Node node1; Node node2; float x,y; // other members }; |
1 2 3 | entity : ^Entity.node2 = node_ptr; entity->x += dx; entity->y += dy; |
1 2 3 4 5 6 7 8 9 10 11 12 | Entity :: type struct { #label kill_list node1: Node; #label need_processing_list node2: Node; x,y: float; } //... entity : ^Entity.need_processing_list = node_ptr; entity->x += dx; entity->y += dy; //... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | Entity :: type struct { using pos: Vec2 name: string } Frog :: type struct { using entity: Entity jump_height: f32 } f: Frog f.x = 1 // access subtype's used fields and dereferences when needed using f x = 1 // f's members are in this namespace now thing :: proc(e: Entity) { ... } thing(f.entity) thing(f) // Maybe this should work |
gingerBill
P.S. You'll notice, semicolons are now optional. It just looks weird to me mainly because I'm not used to it :P
Mr4thDimentiongingerBill
P.S. You'll notice, semicolons are now optional. It just looks weird to me mainly because I'm not used to it :P
Ahaha, I really like semicolons. Even way back when I was using lua which didn't require them I eventually decided to always use semicolons as a matter of style.
gingerBill
Weird that you ask that Allen, as I was just thinking the exact thing before reading this post. I've been making "everything is a namespace" at the moment which is very similar to Jai's using or Pascal's with. As a consequence this brings up questions about subtyping.
The first that I thought of going from a subtype to the "base type".
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Entity :: type struct { using pos: Vec2 name: string } Frog :: type struct { using entity: Entity jump_height: f32 } f: Frog f.x = 1 // access subtype's used fields and dereferences when needed using f x = 1 // f's members are in this namespace now thing :: proc(e: Entity) { ... } thing(f.entity) thing(f) // Maybe this should work
If this works, then I should be able to pass the Frog type to any procedure that takes an Entity type because it subtypes Entity. So why not make it work in reverse?
But the problem then comes down to two things, semantics and syntax. When does it work and how do you define when it is allowed? I'll have to think it through fully before implementing.
I do want to implement tagged/discriminated unions too into the language which should help with a lot of the same problems but with a different memory layout (which is much better than this subtyping method).
P.S. You'll notice, semicolons are now optional. It just looks weird to me mainly because I'm not used to it :P
CaptainKraft
If tagged unions work better than subtyping, why introduce it at all?
ClysmiC
I don't know about Go, but I know that there are some situations in JS that are ambiguous and require semicolons if you want the code to be interpreted correctly. I would definitely recommend using them in JS. Also, I think semicolons are actually quite important if you want your language to support multi-line statements (which it should). You can work around this in JS by carefully choosing where to split your lines, but it's kind of a mental burden and prone to mistakes.
1 2 3 | if - the next token is not on the same line, no need for a semicolon else if - the next next is a close brace, no need for a semicolon else - semicolon is needed (multiple statements on a single line) |
gingerBill
Valmar:
timothy.wright:
I think Go got a lot of thinks correct but a lot of things wrong for it to replace C/C++. Mainly garbage collection and ability to do "unsafe" things is restricted and limiting. Having written hundreds of thousands of lines of Go already, I can say for definite, I cannot replace C/C++ (in their domains).
gingerBill
I'm not even sure if I want to add overloading to the language as it adds a bit of complexity to the type system and namespacing. I'd say 99% of my "needs" for overloading come from mathematical types and operations. Having vectors as first class type (the mathematical kind not the silly C++ construct), infix/postfix calls, and nested procedures in the language aids a lot of my problems are already.
1 2 3 4 | abs :: overload{ (f : float ) -> float{return ...}, (f : int ) -> int{return ...}, ... } |
gingerBill
I should note, when I'm talking about "Go getting a lot right", I'm not just talking about fast compilation speeds. I'm talking about how simple, elegant, and pragmatic the language is but still expressive. I can keep the entirety of the language within my head which increases my sanity of life (which cannot be said for C++).
1 2 3 | #define cbrt(x) _Generic((x), long double: cbrtl, \ default: cbrt, \ float: cbrtf)(x) |