View · Search · Index
No registered users in community xowiki
in last 10 minutes

Re: [Xotcl] Class unknown -> create is considered harmful

From: Gustaf Neumann <neumann_at_wu-wien.ac.at>
Date: Wed, 07 Jan 2009 14:45:22 +0100

Dear Ben,

i do agree with you, that the default unknown handler for
classes/metaclasses is harmful. i prefer as well the explicit
create/new statement for various reasons.

The handler is a heritage from OTcl, and the reason XOTcl
keeps the heritiage is backward compatibility. Many programs
simply use unknown....

However, maybe we should mark its usage as deprecated and
remove it in future versions, such as XOTcl 2.0....

best regards
-gustaf neumann

Ben Thomasson schrieb:
> Hi XOTcl developers,
>
> I have been using XOTcl for a while and I have discovered that the
> default implementation of the Class unknown method is harmful to large
> scale development. The default implementation calls create from the
> unknown method. Here is an example that shows the problem:
>
> Class A
>
> A nstproc doX {} { puts done}
>
> A intsproc doY {} { puts done }
>
> The problem here is that misspellings of class methods will cause
> objects to be created instead of methods to be defined on the class.
> Here we will have an object named ::nstproc and one named ::intsproc
> which are both misspellings of instproc.
>
> There is a simple fix for this:
>
> Class proc unknown { args } {
>
> error "[ self ] Unknown command: \"$args\""
>
> }
>
> Class instproc unknown { args } {
>
> error "[ self ] Unknown command: \"$args\""
>
> }
>
> This will require classes and objects to be created explicitly with
> the create or new method. I find this preferable to having mistakes
> silently ignored. I have seen this problem in the wild as well as
> in my code. XOTclIDE had several misspellings that were ignored
> until I loaded with my fix. Of course existing XOTcl projects
> will have to be modified to insert create methods where needed.
>
> Ben Thomasson
> ------------------------------------------------------------------------
>
> _______________________________________________
> Xotcl mailing list
> Xotcl_at_alice.wu-wien.ac.at
> http://alice.wu-wien.ac.at/mailman/listinfo/xotcl
>