Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RFC for shorter vector constructor #75

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

petrihakkinen
Copy link
Contributor

@petrihakkinen petrihakkinen commented Nov 19, 2024

Add RFC for replacing the current vector constructor (vector.create) with a less verbose version (vector).

Rendered

@petrihakkinen
Copy link
Contributor Author

petrihakkinen commented Nov 19, 2024

After a long think I decided to propose the deprecation and eventual removal of vector.create in favor of vector in the RFC because I think it would be better for the language in the long run to have only one constructor. If you think this is a too big breaking change we can modify the RFC to keep the old version as an alias. I don't have a strong opinion on that but we'd prefer some officially sanctioned way to disable vector.create (or any other built-in) locally for our codebase in case vector is added but vector.create is not deprecated.

@jackdotink
Copy link
Contributor

Personally I would like to see special syntax for creating vectors, such as <x, y, z>.

@vegorov-rbx
Copy link
Collaborator

I don't think we will be adopting this.
Reasoning for current constructor was already discussed in the vector library RFC and we have selected that option to go forward.

In a way, this RFC was already rejected in the discussion of that RFC.

@petrihakkinen
Copy link
Contributor Author

I read through the previous discussions again and I guess the main reason for choosing vector.create is consistency with buffer.create? That is a valid point but at least in our codebase the number of vector creations far outweigh buffer creations. For example, in one of our products there is over 15000 calls to the vector constructor where as buffer.create calls can be counted with fingers. Many of the calls are inline as function arguments (colors, offsets and the like) where extra verbosity starts to affect readability. Granted, buffers is a newer feature but vector is such a commonly used primitive in the domains of games and graphics that we think it could justify having a bit shorter syntax for them.

@alexmccord
Copy link
Contributor

I don't think we will be adopting this. Reasoning for current constructor was already discussed in the vector library RFC and we have selected that option to go forward.

In a way, this RFC was already rejected in the discussion of that RFC.

I don't think this accurately conveys what actually happened with the syntax for vector creation. We talked about a whole bunch of them:

  1. vector(x, y, z)
  2. [x, y, z] following usual notation in linalg
  3. <x, y, z>
  4. |x, y, z|

I feel a strong urge to mention that I never liked the last two, but I digress.

The reason why we split out the vector creation shorthand from the RFC was to allow it to go through, and then let someone talk about the shorthand separately if they're annoyed by vector.create(x, y, z) being the way to create them.

So I don't think it's fair to automatically reject this RFC.

@vegorov-rbx
Copy link
Collaborator

I did not mean to reject it automatically, I reject it based on what is proposed.

@bradsharp
Copy link
Contributor

Also want to mention table.create as additional art.

@vegorov-rbx vegorov-rbx requested a review from ccuser44 December 16, 2024 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

6 participants