dbaumgarten / yodk

Development Kit for Starbase's ingame programming language YOLOL
MIT License
57 stars 16 forks source link

Possiblity of adding Struct to nolol #62

Open Woccz opened 3 years ago

Woccz commented 3 years ago

Following #48/#63.

Perhaps give programmers the ability to create Structs in nolol, as almost a precursor to classes. These Structs would make it easier to group related variables and would be treated as a programmer-defined type, similar to C, and could be passed to macros which act almost as a class method.

No actual YOLOL operations can be performed on a Struct, only on its child variables.

Early into compilation all Structs can be removed and their child variables be replaced by locals, as Struct is merely a way to improve readability, understandability, and reusability of nolol code.

An example of a potentially useful Struct, that could even be included in the "std" library is:

Struct 3DCoordinate
    Num x
    Num y
    Num z
end

I'm sure there would be many other possible uses for Struct.

Thank you.

dbaumgarten commented 3 years ago

Especially when combined with macros this would make some things pretty simple. For example the matrix-math used in ISAN.

When designing the type-system it should be done in a way that it is prepared for the future addition of structs.

My only concern is, that it might make nolol harder to learn for beginners.

Woccz commented 3 years ago

I'm not sure why it would make nolol harder for beginners, as you can still use all the code without ever touching structs, can you not?

dbaumgarten commented 3 years ago

Probably depends on how much structs are used in the standard-library.

Its not really that I think this one specific feature will make it to complicated. It's more a general feeling that if every feature that somehow makes sense gets added, nolol will eventually become a horrible mess.

(This is not a "no" to structs. I just want to be careful about feature-creep in general.)

Woccz commented 3 years ago

I see. Perhaps structs could be kept to their own, higher-level part of the standard library so that beginners do not have to deal with them.

I think nolol having many features is a good thing, however they should probably be built in layers to allow for the user to choose what level they wish to use nolol at.

I think nolol does a great job of this currently, by still allowing goto, despite having built-in loops, and features such as macro are only for those who wish to delve into them.

If nolol continues to implement new features with this downward compatibility principle, I believe it will become a language that is easy to pick up for beginners, yet offers helpful functionality for specific applications.