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

Underscore property names versus variables. #12

Closed
tobydriscoll opened this issue Jul 15, 2014 · 4 comments
Closed

Underscore property names versus variables. #12

tobydriscoll opened this issue Jul 15, 2014 · 4 comments
Labels

Comments

@tobydriscoll
Copy link
Member

I appreciate the convenience of having underscore-trailing property names to avoid clash with internal names. However, those properties are exposed to the user. Wouldn't it be better to reverse and use the underscores with the internal names?

@ehkropf
Copy link
Collaborator

ehkropf commented Jul 15, 2014

I now remember another reason I was using the underscores. Say a class has a property foo. Let C be an instance of that class. You also want a function with the same name as the property to access it via the syntax foo(C). Using the classdef syntax precludes having the property with the same name as the function.

The current mess is partly due to the conversion. For example, in an effort to make the polygon class behave as it did before it was converted, I needed to salvage functions such as alpha and vertex, but I was in a rush (lazy?) and just stuck the underscores on the property names. I believe I thought at the time the rule should be "if there is a function to read the property, or if the property probably won't be accessed directly by the user that often, then the property gets an underscore." It clearly wasn't well thought out.

Having said that, I'm still not sure that's the wrong way to look at it. It seems to be "the matlab way" to access properties with the foo(C) syntax, though of course I can't think of an example this second which makes my case.

@tobydriscoll
Copy link
Member Author

I don't disagree regarding the matlab way, though one irritation is that properties get tab completion whereas the older syntax does not.

Let's do nothing about this for now.

@ehkropf
Copy link
Collaborator

ehkropf commented Jul 15, 2014

Tab completion with the classdef syntax is completely broken. It occasionally works if you have an instance of a class in memory, but if not you get nothing.

@ehkropf
Copy link
Collaborator

ehkropf commented Aug 4, 2014

Closing as subsumed under #27.

@ehkropf ehkropf closed this as completed Aug 4, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants