From 5371526595903a1c98adc14e834be674ee24840f Mon Sep 17 00:00:00 2001 From: Andreas Reischuck Date: Mon, 4 Apr 2016 00:05:22 +0200 Subject: [PATCH 1/4] proposed introduction of meta types --- text/00000-introduce_meta_types.md | 71 ++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 text/00000-introduce_meta_types.md diff --git a/text/00000-introduce_meta_types.md b/text/00000-introduce_meta_types.md new file mode 100644 index 0000000..fe79283 --- /dev/null +++ b/text/00000-introduce_meta_types.md @@ -0,0 +1,71 @@ +# Introduce Meta Types + +- Created: 2016-04-03 + +## Summary +[Summary]: #summary + +The user should be able to extend the type system with custom meta types and a consistent syntax. + +## Motivation +[Motivation]: #motivation + +Classical system languages have a very limited type system. + +Even with operator overloading of C++ a class or struct cannot build all the necessary abstractions. For example to model strict value types or even actors. + +This RFC proposes the introduction of a more flexible type system. + +## Detailed design +[Detailed design]: #detailed-design + +In C++ we know the following type categories: + +- `basic` - bool, int, float (compiler & system provided value types) +- `enum` - user defined names for values +- `struct` & `class` - OOP structures + +Instead of treating these special, they should be one of many. Everything is just a type and the compiler has to know how to deal with instances of them. + +It might look like this: + +- `type rgb : value …` - value type semantics for user defined types +- `type color : enum …` - list of values +- `type person : struct …` - for structured data declaration + +This syntax is very consistent and keeps the number of keywords low. + +We might wand to provide more meta types in the language. Each should be discussed in all details in a seperate RFC. + +- `type expression : union …` - a variant type that contains one of the types +- `type expression : actor …` - restricts access outside of the actor + +## Drawbacks +[Drawbacks]: #drawbacks + +### Default types need more letters to write. + +I believe it's worth to have a very consistent syntax and to keep the keyword introduction to all declarations. + +## Alternatives +[Alternatives]: #alternatives + +We can keep the classical type system and try to make struct/class flexible enough to model the desired behaviors. +> I doubt this is fully possilbe. + +It might also be possible to achieve the same goal with a clever macro system. +> This will lead to some surprises for the developer. With the proposed syntax it is at least clear that we define a type and that the behavior is somewhat restrictet to the declared type. + +Some behavior is achievable with template meta programming or something similar. +> The proposed system is more flexible. Template meta programming will need a very elaborative syntax, that makes it hard to get readable APIs. + +## Unresolved questions +[Unresolved questions]: #unresolved-questions + +### Which meta types should be built in? + +It is beyond the scope of this RFC. Each meta type should be proposed as a seperate RFC. + +### How are user defined meta types defined? + +No proposals exist so far. Please suggest something in a new RFC. From f56eeab6ff92ddd7924f9a3b095fa4a66408e6ba Mon Sep 17 00:00:00 2001 From: Andreas Reischuck Date: Wed, 25 May 2016 09:54:46 +0200 Subject: [PATCH 2/4] assigned pr number --- ...00-introduce_meta_types.md => 00004-introduce_meta_types.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename text/{00000-introduce_meta_types.md => 00004-introduce_meta_types.md} (97%) diff --git a/text/00000-introduce_meta_types.md b/text/00004-introduce_meta_types.md similarity index 97% rename from text/00000-introduce_meta_types.md rename to text/00004-introduce_meta_types.md index fe79283..d4a9a14 100644 --- a/text/00000-introduce_meta_types.md +++ b/text/00004-introduce_meta_types.md @@ -35,7 +35,7 @@ It might look like this: This syntax is very consistent and keeps the number of keywords low. -We might wand to provide more meta types in the language. Each should be discussed in all details in a seperate RFC. +We might want to provide more meta types in the language. Each should be discussed in all details in a seperate RFC. - `type expression : union …` - a variant type that contains one of the types - `type expression : actor …` - restricts access outside of the actor From 912c64017799ffc89753d17fe48c038baf00ee1b Mon Sep 17 00:00:00 2001 From: Andreas Reischuck Date: Tue, 27 Dec 2016 00:16:29 +0100 Subject: [PATCH 3/4] fixed_a_typo --- text/00004-introduce_meta_types.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/00004-introduce_meta_types.md b/text/00004-introduce_meta_types.md index d4a9a14..c25d7bc 100644 --- a/text/00004-introduce_meta_types.md +++ b/text/00004-introduce_meta_types.md @@ -51,7 +51,7 @@ I believe it's worth to have a very consistent syntax and to keep the keyword in [Alternatives]: #alternatives We can keep the classical type system and try to make struct/class flexible enough to model the desired behaviors. -> I doubt this is fully possilbe. +> I doubt this is possible. It might also be possible to achieve the same goal with a clever macro system. > This will lead to some surprises for the developer. With the proposed syntax it is at least clear that we define a type and that the behavior is somewhat restrictet to the declared type. From 0a1dc2368c6361af23e98126cb35fb737e83e0f0 Mon Sep 17 00:00:00 2001 From: Andreas Reischuck Date: Sun, 28 May 2017 19:34:37 +0200 Subject: [PATCH 4/4] renamed file for new PR# --- ...0004-introduce_meta_types.md => 00016-introduce_meta_types.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename text/{00004-introduce_meta_types.md => 00016-introduce_meta_types.md} (100%) diff --git a/text/00004-introduce_meta_types.md b/text/00016-introduce_meta_types.md similarity index 100% rename from text/00004-introduce_meta_types.md rename to text/00016-introduce_meta_types.md