Replies: 6 comments 30 replies
-
I don't have any immediate feedback on this issue, following for (hopefully) more discussion. Also, if you're on Facebook, consider joining the largest Perl Programmers group. Even more great discussion there! |
Beta Was this translation helpful? Give feedback.
-
@Ovid Sorry but why did you use
As for the issue I think simply disallowing |
Beta Was this translation helpful? Give feedback.
-
Having reserved field names is a noxious design smell. One needs to be able to name a field using any character string or valid generic identifier without limit. No special casing of things like |
Beta Was this translation helpful? Give feedback.
-
I have an updated Corinna design proposal that I would hope would make everyone happy.
I want to emphasize that the precedent here is what you can do with blessed hashes, full user control over what the invocant and the fields are named. Having reserved I also consider it good design in many cases to give the invocant a more descriptive name, as I illustrated with my code example above representing a numeric division method, and since the invocant is logically a parameter, users should be able to name it too based on context. Not allowing naming of the invocant is like forcing all the parameters to be named eg Thank you for your consideration. |
Beta Was this translation helpful? Give feedback.
-
I just came across this discussion, and thought I would add my mite. Late as it may be. Naming a field So I'd suggest that when someone declares
Then, if they don't want those warnings, they can either rename to fields to something less bloody-minded, As for future-proofing the addition of further automatic variables, I honestly don't see that The chance of a future auto-variable conflicting with existing fields or variables would be greatly diminished To be clear, I'm suggesting that |
Beta Was this translation helpful? Give feedback.
-
I'm good with Damian's suggestion of using $SELF and $CLASS for the auto-injected variables, as being an improvement over the lowercased versions. However, while this would lower the chance of conflict, we must still have zero reserved names, and hence naming fields $SELF or $CLASS must be allowed, and if that happens, there is still the warnings about because you did that the fields can only be referenced via the reader/writer methods and not in $foo syntax. |
Beta Was this translation helpful? Give feedback.
-
Doing a lot of research into OOP right now and I've realized we might have a potential issue I hadn't thought of before.
If we inject
$class
and$self
variables into a method, what then? The simplest solutions:$class
an$self
becomeclassname
andself
keywords (but this seems to defeat the spirit of lexicals)$mop
/$meta
?)Also, if you're on Facebook, consider joining The Perl community. Lots of great discussion there.
Beta Was this translation helpful? Give feedback.
All reactions