On Dec 29, 1:25 am, Emeka <[email protected]> wrote:
[...]
> Is Prototype JavaScript's way of solving Expression Problem? [...]
The short answer is that Brendan Eich probably wasn't thinking about
it when he built the language in the 9 days he had available. The
longer answer is that yes it is possible.
In regards to adding new methods:
Javacript allows monkey patching. You can add and replace methods at
any time on an object which is then inherited at run time by any
subtypes. While this can be used to solve the Expression problem much
easier than in say Java, there is always the issue of name clashes
(did someone else monkey-patch an incompatible method of the same
name?). Of course ES5 allows you to prevent other people from
modifying and object after you've augmented it, but then that could
put you back into the same problem if they need to do the same thing
you did and are forced to wrap the object, breaking the inheritance
constraint.
In regards to adding new values, you can create a new function to
represent it as functions play a duel role in the language:
function MyNewType(value){
this.value = value;
}
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]