maxtaco / coffee-script

IcedCoffeeScript
http://maxtaco.github.com/coffee-script
MIT License
727 stars 58 forks source link

Iced confused by qualified methods named defer #68

Closed neverfox closed 11 years ago

neverfox commented 11 years ago

I'm using a library (Durandal) that has a function system.defer that takes one argument, a callback. You would normally write:

system.defer (dfd) ->
 ...

I get compile errors when I try to do this in IcedCoffeeScript:

system.defer defer dfd

It doesn't seem to be able to tell that the first defer, even though it's a method of system isn't an IcedCoffeeScript directive.

maxtaco commented 11 years ago

Yeah, that makes sense. defer is an IcedCoffeeScript keyword, which is rewritten by the compiler. However, there's any easy workaround:

system["defer"] defer dfd

This should work, let me know if not...

neverfox commented 11 years ago

Thanks. I should have thought to do that.

icflorescu commented 11 years ago

The above mentioned workaround also comes handy for people using the defer function in underscore.js.