-
Notifications
You must be signed in to change notification settings - Fork 2
RFC: type vs alias #3
Comments
I think if you're wanting a more C/C++ feel to the language, I think staying with typedef old_type newType; But yours could be:
|
Good point about Visual Basic. However, when thinking about typedef __detail::_Adaptor<_Engine, _Dist> engine_value_type;
typedef __detail::_Hash_node<_Value, __cache_hash_code> _Node;
typedef integral_constant<bool, __stored_locally> _Local_storage; Obviously some of the above are due to underscores in identifiers, which (as of now) Arua will not allow. The underscores are used as internal identifiers, which should be properly zoned away as to not allow public access anyway. So as an experiment, let's remove the underscores and use
and without
The common theme with In my personal opinion, the former example is more readable than the latter. With readability in mind, I think it's a fair tradeoff. |
Ah okay, well if you're going for a more convertible language this would be the most viable option. P.S, in that example of using alias with "as", I notice the CPP template syntax. Will Aura have templates? Obviously I understand it would be in a later update but, is it a possibility? |
@polyg0n I'm pretty sure I want them. I want to make sure they mesh well with the trait-based design. If they are incorporated, they will semantically resemble Java's generics more than C++'s templates, but I'm sure underlying implementation will be more similar to templates than generics. I haven't given them a ton of thought yet. Per-type generics are almost strictly an inheritance thing. I could easily see per-function generics, though. |
@Qix-, honestly per function generics would be beautiful. I've used C++ templates and Java generics both of which are powerful and great. But per-function generics would be awesome. |
The top-most post has been updated to reflect the current state of the RFC. |
|
@Qix- So you're going for more a TypeScript style of type aliasing?[ as far as syntax goes ] but you're creating an new physical type [ as far as what the compiler sees ] type someType = string Possible Arua implementation -
|
Precisely, though backwards. |
type
andalias
both create a new type identifier in the unit scope, howevertype
creates a new type whereasalias
creates a new name for an existing type.type
creates a 'copy' of an existing type and gives it a new name. New traits can be applied to new type definitions without affecting the original type.As seen above, this is the critical element used by the
str8
type - a UTF-8 string.str
now inherits the array property.length
, and now allows more traits and methods to be applied to it without those types being applied to the[u8]
type itself.alias
gives a new name to an existing type without creating a new type altogether. All applications of traits onstr
will affectstr8
.The above example is what creates the built in
str
type -str
is really juststr8
.Here is a truth table for
type
vsalias
:T as U
type
alias
The text was updated successfully, but these errors were encountered: