You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In #778 I'm introducing support for user-defined stack allocated types. In pretty much all languages out there that have a notion of classes, the class keyword is typically used for a heap allocated type that you address through a pointer, and something like a struct keyword is used (if supported at all) for stack types.
This means that seeing class inline Foo { ... } is a bit odd, because class might have you believe it's a heap type, while inline means it's in fact a stack type.
To resolve this, we'll replace the class keyword with the type keyword. So instead of this:
class User { ... }
class inline Number { ... }
You'd write the following:
type User { ... }
type inline Number { ... }
For traits we'll continue to use the trait keyword as there's no benefit to changing it.
TODO
Support both class and type at the parser level
Update the Tree sitter grammar to support both class and type
Update Vim syntax file
Update VS Code extension
Update the code formatter to replace class with type automatically
Update the documentation
Related work
No response
The text was updated successfully, but these errors were encountered:
Now that types are no longer guaranteed to go on the heap, the use of
"class" can be confusing as this is typically used for types that go on
the heap. In addition, our types weren't really traditional classes to
begin with due to the lack of support for inheritance.
The `class` keyword is still supported but is now deprecated, and the
`fmt` command automatically replaces it with the new `type` keyword.
This fixes#779.
Changelog: changed
Now that types are no longer guaranteed to go on the heap, the use of
"class" can be confusing as this is typically used for types that go on
the heap. In addition, our types weren't really traditional classes to
begin with due to the lack of support for inheritance.
The `class` keyword is still supported but is now deprecated, and the
`fmt` command automatically replaces it with the new `type` keyword.
This fixes#779.
Changelog: changed
Description
In #778 I'm introducing support for user-defined stack allocated types. In pretty much all languages out there that have a notion of classes, the
class
keyword is typically used for a heap allocated type that you address through a pointer, and something like astruct
keyword is used (if supported at all) for stack types.This means that seeing
class inline Foo { ... }
is a bit odd, becauseclass
might have you believe it's a heap type, whileinline
means it's in fact a stack type.To resolve this, we'll replace the
class
keyword with thetype
keyword. So instead of this:You'd write the following:
For traits we'll continue to use the
trait
keyword as there's no benefit to changing it.TODO
class
andtype
at the parser levelclass
andtype
class
withtype
automaticallyRelated work
No response
The text was updated successfully, but these errors were encountered: