| FazBrowse Wikipedia Viewer | Main Page | | |
| Viewing: https://en.wikipedia.org/wiki/LiveScript_(programming_language) |
| Contents |
|---|
| Name mangling |
| Operators as functions |
| References |
| LiveScript | ||
|---|---|---|
| Paradigms | Multi-paradigm, functional, object-oriented | |
| Designed by | Jeremy Ashkenas, Satoshi Murakami, George Zahariev | |
| Developers | (same) | |
| First appeared | 2011;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 manglingeditAt 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 functionseditWhen 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
Referencesedit
"Chapter 4. How JavaScript Was Created". speakingjs.com. Archived from the original on 2020-02-27. Retrieved 2017-11-21.
| ||