Richard,

On 29 Gen, 13:43, Richard Quadling <rquadl...@googlemail.com> wrote:
> 2009/1/28 Diego Perini <diego.per...@gmail.com>:
>
> > The other good thing you are doing with JSLint is enforce the type of
> > each function, I mean the return type. I have been told several time
> > that not being a strict typed language it doesn't matter blah..blah
> > blah.
>
> Why would you cripple the language by enforcing return types?
>

Hey it is Douglas Crockford JSLint saying that, not me, I am just
happily supporting the idea...

Are you saying that C and Java are crippled languages because they
enforce return types ?

Just wanted to point out that doing what Crockford suggests will help
write more robust javascript, though that doesn't mean you may be able
to achieve the same goal using functions returning mixed types. Not
everybody is able to write and work well in a polymorphic environment.

> Many times it is useful to return a boolean False if something doesn't
> work and the appropriate type when it does.
>

You can do the same with any type without mixing:

- object, return null instead of an existing object (null is still an
object)
- string, return empty string instead of not empty string
- number, return negative number instead of a positive
- boolean, return boolean false instead of boolean true

I agree about that methodology you enforce is a shortcut most of the
time, but I would try to avoid that if possible.

> So mainly return types are mixed.
>

Yep...in Prototype, functions return types are mixed (but only in some
special circumstance), I don't have them enumerated and I don't know
which one does that and I don't see any documentation explaining which
one does .... :-)

Diego Perini

> --
> -----
> Richard Quadling
> Zend Certified Engineer :http://zend.com/zce.php?c=ZEND002498&r=213474731
> "Standing on the shoulders of some very clever giants!"
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to