3 ms·
A few years ago i was also thinking of how Oberon-07 could be extended to support more generic types - mainly so containers, etc, can be more type safe - and pr
by badsectoracula 4y ago
A few years ago i was also thinking of how Oberon-07 could be extended to support more generic types - mainly so containers, etc, can be more type safe - and pretty much came to the same conclusion that putting types on the modules themselves is by far the simplest approach. Though my approach was a bit different (judging from the code examples) in that parametric modules were more like templates that were specialized during import.
Specifically in Oberon-07 when you have a module "Foo" with a type "Bar" you use it in another module as "Foo.Bar". With parametric modules, a "Foo<T>" module would need to be imported an a specialized form as -e.g.- "Foo<INTEGER>" and thus the "Bar" type would need to be used as "Foo<INTEGER>.Bar".
In my mind that was both the simplest and smallest change that would allow for the most flexibility (the parameters would be any token acceptable by the language, not just types, meaning that they could be used for constants or even affect other imports).
I did consider implementing a compiler for this, but then i decided that if i'm going to make a compiler for an incompatible language that already practically nobody uses, might as well make my own language that also changes some things i dislike about Oberon-07 (like the uppercase keywords, using # for the inequality string and * to export stuff from modules).
- pjmlp 4y agoBesides that, Active Oberon already supports generics in a way similar to Modula-3.
- Rochus 4y agoThe original Active Oberon (Reali, 2004) didn't have generics; you probably mean the ETH Oberon (2019) Language Report draft by Felix Friedrich; I don't think it's implemented somewhere.
- pjmlp 4y agoNaturally I mean the latest version. As for it being implemented, I was assuming that by now it already was, given that it is still being actively developed.
- Rochus 4y agoThe language proposed by Friedrich is actually a different one than Active Oberon, even if the latter is mentioned as a basis. I didn't find a compiler yet which implements the proposed templates; if you know one please post a link.