Add a New Comment (Rich Markup)
Comment Type & Canned Response: None None > Multiple Canned Responses Fixed in development Crash with no stack trace Already fixed in newer version Fixed in stable Bad description Bad description and crash Bad stack trace Obsolete version Duplicate and not fixed Duplicate and needs more info Duplicate and fixed Need info and old
I was just pointing out what Matlab does, not that we need to follow them.
However, from a coding/confusion perspective would it make sense not to have the same name for two different things? I like Perl, but one of the dings against it is that there is almost nothing to prevet you from coding really bad, unintelligible, unmaintainable code. Maybe it makes sense to enforce this naming restriction just to help less sophisticated programmers (i.e. scientists).
I don't know why it would cause trouble. Even something like the following seems like it should work.
classdef foobar properties foobar; end methods function obj = foobar (...) obj.foobar = ...; end end end
Inside methods, isn't it required to use obj.property to access properties? If so, then I don't see a conflict between property names and the constructor (class) name. It seems to me that you could even have a method that called the constructor to create another object of the same type without having a conflict.
Am I missing something?
Matlab does not allow a property inside a class to have the same name as the class. Octave does allow this. Is there any significant architecture issue to allowing / disallowing this behavior? In any case, I am just pointing it out.
Sample code in file testprop.m
classdef testprop properties testprop = 0; end end
Then execute
x = testprop x.testprop
(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)
Attach Files: Comment:
No files currently attached
Depends on the following items: None found
Items that depend on this one: None found
There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.
Only project members can vote.
Please enter the title of George Orwell's famous dystopian book (it's a date):
Follow 2 latest changes.
Copyright © 2023 Free Software Foundation, Inc. Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved. The Levitating, Meditating, Flute-playing Gnu logo is a GNU GPL'ed image provided by the Nevrax Design Team. Source Code
Powered by Savane 3.10