Skip to content

Classes - #229

Open
andyfriesen wants to merge 5 commits into
masterfrom
classes-v2
Open

Classes#229
andyfriesen wants to merge 5 commits into
masterfrom
classes-v2

Conversation

@andyfriesen

@andyfriesen andyfriesen commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Rendered

We jumped the gun on merging this RFC. Some light edits are necessary.

Most notably, creating new class instances is now always done via a static .new() method.

Class constructors are described separately at #210
Inheritance is described at #230

Class instances are now always created via ClassName.new()
This was referenced Jul 16, 2026
This paragraph is obsolete.  Clip.
Comment thread docs/syntax-classes.md Outdated
Comment thread docs/syntax-classes.md Outdated
Whoopsies.  Leading `_`s only.
@deviaze

deviaze commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

As extensively discussed off-RFC, I still feel banning users from defining new and forcing users to define __init to define new (except when inheritance complicates things) is a confusing mental model.

As someone who's used the WIP experimental classes feature for useful code, I very much appreciate that POD structs (classes with default constructor) just look like named tables.

I still feel T() (with T { } syntax) makes more sense for POD nominal structs but T.new() (or another factory function that acts like a constructor) with user defined arguments and user defined behavior makes more sense for classes with actual constructor logic.

@deviaze

deviaze commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

We had a discussion on forced .new vs. constructors that I was recommended to post here for publicity/transparency:

Screenshot_20260722_181516_Discord

@TenebrisNoctua

Copy link
Copy Markdown

As extensively discussed off-RFC, I still feel banning users from defining new and forcing users to define __init to define new (except when inheritance complicates things) is a confusing mental model.

As someone who's used the WIP experimental classes feature for useful code, I very much appreciate that POD structs (classes with default constructor) just look like named tables.

I still feel T() (with T { } syntax) makes more sense for POD nominal structs but T.new() (or another factory function that acts like a constructor) with user defined arguments and user defined behavior makes more sense for classes with actual constructor logic.

I proposed an alternative solution for this on this comment here, for anyone to see:
#210 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants