FazBrowse Wikipedia Viewer | Main Page |
Search Wikipedia:
|
Viewing: https://en.wikipedia.org/wiki/LiveScript_(programming_language)

LiveScript (programming language)

Contents
    Name mangling
    Operators as functions
References

{{cite web |url=https://github.com/gkz/LiveScript/tags |title=LiveScript Releases |website=[[GitHub]] |access-date=21 February 2021}}</ref>"},"typing":{"wt":"[[Dynamic typing|Dynamic]], [[Strong and weak typing|weak]]"},"scope":{"wt":"[[Scope (computer science)|Lexical]]"},"operating system":{"wt":"[[Cross-platform software|Cross-platform]]"},"license":{"wt":"[[MIT License|MIT]]"},"file ext":{"wt":"<code>.ls</code>"},"influenced by":{"wt":"[[JavaScript]], [[Haskell]], [[CoffeeScript]], [[F Sharp (programming language)|F#]]"}},"i":0}}]}'>
LiveScript
ParadigmsMulti-paradigm, functional, object-oriented
Designed byJeremy Ashkenas, Satoshi Murakami, George Zahariev
Developers(same)
First appeared2011;15 years ago (2011)
hello=-> console.log'hello, world!'

While calling a function can be done with empty parens, hello(), LiveScript treats the exclamation mark as a single-character shorthand for function calls with zero arguments: hello!

LiveScript introduces a number of other incompatible idioms:

Name mangling

edit

At compile time, the LiveScript parser implicitly converts kebab case (dashed variables and function names) to camel case.

\n console.log 'Hello, World!'\n"}}'>hello-world=-> console.log'Hello, World!'

With this definition, both the following calls are valid. However, calling using the same dashed syntax is recommended.

A pipe operator |> passes the result of an expression on the left of the operator as an argument to the expression on the right of it. LiveScript supports these, as do some other functional languages such as F# and Elixir; the argument passed in F# is the last one, but in Elixir is the first one.

capitalize |> console.log\n# > Hello!\n"}}'>"hello!"|>capitalize|>console.log # > Hello!

Operators as functions

edit

When parenthesized, operators such as not or + can be included in pipelines or called as if they are functions.

(+) 222\n# > 333\n\n(+) 1 2\n# > 3\n"}}'>111|>(+)222 # > 333 (+)12 # > 3

References

edit
"Chapter 4. How JavaScript Was Created". speakingjs.com. Archived from the original on 2020-02-27. Retrieved 2017-11-21.
  • ↑

  • View original on Wikipedia | Back | FazBrowse Home