Git Product home page Git Product logo

liso's Introduction

Liso

Liso is an alternative syntax for Lisp-like languages, implemented here for Racket.

Examples

fib[n] =
   @if n <= 1:
      n
      fib[n - 1] + fib[n - 2]

fib[30]

<=>

(= (fib n)
   (if (<= n 1)
       n
       (+ (fib (- n 1))
          (fib (- n 2)))))
(fib 30)

There are many more examples here, including examples of macros and operator macros.

Using

You can try out the first version by putting the following line at the beginning of a source file:

#lang planet breuleux/liso

For the bleeding edge version, just download the code somewhere and then put this at the beginning:

#lang reader "/path/to/liso/lang/reader.rkt"

Then, execute as follows:

racket file.liso

Highlights

  • It is a pure operator syntax, a particular implementation of what I call "o-expressions". I made o-expressions for a new programming language that I am designing, so they were not designed to work with Lisp-like languages. However, I believe that they are a competent alternative to s-expressions, so there is no harm trying.

  • The syntax cannot be customized from within itself: operator priority is predetermined, even for custom operators.

  • It is general and homoiconic. All syntactic elements behave the same in all contexts, they have no associated semantics, and they reduce to extremely regular structures.

  • It does support macros. In fact, you can use Racket's macro system without any changes to their underlying logic. See here for example.

Precedence rules

precedence

Rules

+ Rule       + O-expression              + S-expression
| Operator   | x <operator> y            | (<operator> x y)
|            | x <op> y <op> z           | (<op> x y z)
|            | x <op1> y <op2> z         | (<op1>_<op2> x y z) (op1 != op2)
| Apply      | x y                       | (apply x y)
|            | x y z                     | (apply (apply x y) z)
| List       | []                        | (list)
|            | [x, ...]                  | (list x ...)
| Apply+List | x[y, ...]                 | (x y ...)
| Group      | {x}                       | x
|            | {x, y, ...}               | (begin x y ...)
| Arrow      | x => y                    | (x y) (for all x)
| Contro     | @K : x                    | (K x)
|            | @K x : y                  | (K x y)
|            | @K x, y : {a, b, c}       | (K (begin x y) a b c)
| Sexp       | (...)                     | (...)

Aliases

+ Usual syntax         + Equivalent operator
| @define spec: body   | spec = body
| @lambda args: body   | args -> body
| @set! var: value     | var := value
| @quote: expr         | ..expr
| @quasiquote: expr    | .expr
| @unquote: expr       | ^expr
| expt[x, y]           | x ** y
| cons[x, y]           | x :: y
| string-append[x, y]  | x ++ y
| not[x == y]          | x /= y
| or[a, b, c]          | a || b || c
| and[a, b, c]         | a && b && c
| not[x]               | ! x

liso's People

Contributors

breuleux avatar

Stargazers

jelly avatar

Watchers

James Cloos avatar jelly avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.