Let's make object construction context-free. #663
Replies: 5 comments 7 replies
-
Also UFCS on types is not context-free in Cpp2: a: = x.Type(y, z); // This |
Beta Was this translation helpful? Give feedback.
-
(I get it, and I thought about this too once, but let me push back on it.) My answer is "but
There are other reasons I actually like And if we specifically want a constructor call, we can express that too with the |
Beta Was this translation helpful? Give feedback.
-
This may be a stupid question, but how do you call a constructor or operator= with explicit this at an out parameter, is there just a special case that assumes the left side of the expression is what the 'this' parameter is assigned to? Or are constructors and constructing operator= functions static members of the type returning an instance?
On 7 September 2023 21:00:46 Sadeq ***@***.***> wrote:
Thanks. I like your opinion. So I should use the : syntax to specially call the constructor, otherwise I can use function-style syntax to treat the constructor as a function in generic programming.
—
Reply to this email directly, view it on GitHub<#663 (reply in thread)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AALUZQPXLSZOZTXK4VU746TXZIRWZANCNFSM6AAAAAA4OPSOBE>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
So this would be valid?
myPtr : *MyType;
myObj := MyType(myPtr,...)
And this would be valid as well?
myObj := MyType(...)
Where ... Denotes whatever the construction parameters may be
I'm probably missing something here, and certainly messing up the syntax, but I think my question is, if type construction involves some magic where the first out parameter is actually treated like a return parameter instead, doesn't that also require context?
On 7 September 2023 21:24:52 Johel Ernesto Guerrero Peña ***@***.***> wrote:
Yeah, for out parameters, you assign to it to call operator=.
—
Reply to this email directly, view it on GitHub<#663 (reply in thread)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AALUZQIU3X3WZW2JEFI66I3XZIURDANCNFSM6AAAAAA4OPSOBE>.
You are receiving this because you commented.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Thanks. Now I understand, and I learned about its use cases.
So I think I should close this discussion as resolved. |
Beta Was this translation helpful? Give feedback.
-
In Cpp1
Type(args...)
is not context-free.In Cpp2
: Type = (args...)
is the equivalent context-free syntax.So Cpp2 can be totally context-free if it forbids the Cpp1's syntax in its pure mode.
Beta Was this translation helpful? Give feedback.
All reactions