On Fri, 22 Jan 2010, Lorenzo Fiorini wrote:
> i understand but declaring parameters both in class definition and in
> method implementation is a duplication of code and as we've seen a
> source of ( formal ) errors.
Yes it is. But I do not think that most of people agree with your
conclusion because it's not the source of formal errors but method
of detecting real errors when declaration and implementation is different.
If you do not like declarations at all then it's your choice but usually
users like strong typing and similar features. They help to locate
errors and typos at compile time. I.e. I still miss compile time support
for method name verification so when I make typo like:
oPrn:AskProperites := .T.
the error is generated at runtime only.
> In class(y) doc methods are always declared without any parameter.
Yes, in Classy it's illegal to use any parameters information in class
declaration. Anyhow it also uses some type of declaration for class
definition. I do not find big difference between validation only method
name and validation of method name with parameters. For people who do
not like declarations at all probably it will be better to make sth like:
create class mysls
method mth1
? mth1
return self
method mth2
? mth2
return self
endclass
Such version really eliminates declarations so you may want to create
new PP rules for class creation which will work in above way. Otherwise
you still have to make at least partial declarations so there is always
chance that you create code where declaration and implementation is
different.
> It would be better to have only one method declaration/implementation
> inside the class definition but if it's not possible declaring methods
> without parameters seems to be the "second best" solution.
See above. Just simply eliminate declarations at all.
But I do not think you will win too much in such way,
All time you safe eliminating declaration you will have
to invest in documentation or you will have to look for
the code to check exact method names and parameters.
Class declaration is minimal class description which is
usually very usable in the future when such class is used.
Especially if you are working in a team or when code it
actively developed for years.
Anyhow it's programmer your choice what to chose and it's
the reason why I enabled such verification only optionally
for -w3 and higher level warning and even in such case leaving
Class(y) compatible declaration method which does not force
strict parameter validation.
best regards,
Przemek
_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour