LiveScript curried functions doesnt work (long arrow -->) #22

Closed
AitorATuin opened this Issue Aug 16, 2013 · 3 comments

Comments

Projects
None yet
2 participants
@AitorATuin

Just trying urequire to use AMD with LiveScript, everything seemed to work as expected but curried functions (long arrow, -->). When trying a file which defines such a function, the compiled error fails to load curry$ (seems that the compiler isnt adding the definition for curry$, lsc -c adds it correctly).

Here are the testing files:

  • hello.ls
define ->
       require! os
       return "hello from the cpu # #{os.cpus!.length}"
  • world.ls
define -> return "world"
  • project.ls
require ['hello', 'world',], (hello, world) ->
        setF = (f, v, o) --> o[f] = v ; o
        console.log hello, world

running: 'urequire nodejs dir -o output_dir' produces the nodejs prepared files, an when executing via node it throws this error:
'ReferenceError: curry$ is not defined'

The problem is in the definition of setF, when using short arrow (->) everything works like a charm.

@anodynos

This comment has been minimized.

Show comment
Hide comment
@anodynos

anodynos Aug 19, 2013

Owner

This is a known issue #8 - the actual problem is that coffeescript (and its descendants) is producing code like curry$ or __slice, __extend etc placed outside the define function. Due to the inefficiency of the urequire's module parsing code (it still uses uglify v1.x), all code outside the define call is not placed in the regenerated code.

I will soon change the parsing code to use esprima and solve this once and for all - something I wanted to do for a long time. Till then its better to use nodejs/commonjs as your source and convert them to UMD or AMD etc that works fine in all cases.

Owner

anodynos commented Aug 19, 2013

This is a known issue #8 - the actual problem is that coffeescript (and its descendants) is producing code like curry$ or __slice, __extend etc placed outside the define function. Due to the inefficiency of the urequire's module parsing code (it still uses uglify v1.x), all code outside the define call is not placed in the regenerated code.

I will soon change the parsing code to use esprima and solve this once and for all - something I wanted to do for a long time. Till then its better to use nodejs/commonjs as your source and convert them to UMD or AMD etc that works fine in all cases.

@ghost ghost assigned anodynos Aug 19, 2013

@anodynos

This comment has been minimized.

Show comment
Hide comment
@anodynos

anodynos Sep 24, 2013

Owner

Fixed in 7ebeab5

Owner

anodynos commented Sep 24, 2013

Fixed in 7ebeab5

@anodynos anodynos closed this Sep 24, 2013

@AitorATuin

This comment has been minimized.

Show comment
Hide comment
@AitorATuin

AitorATuin Sep 27, 2013

nice to know, thanks.

nice to know, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment