A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/benekastah/oppo below:

benekastah/oppo: If javascript is lisp in c's clothing, then oppo is lisp in lisp's clothing, with c's pajamas.

Note to anyone who may care: I haven't used or substantially updated this project in a long time and do not plan on putting any further effort into it. The npm package has been deprecated to reflect this. If you want this to work for you, feel free to fork it.

Oppo is a sweet little lisp for javascript. This is experimental, and therefore any suggestions are welcome.

To install, run the following in your terminal. Make sure you have node.js and npm installed first.

npm install -g oppo@0.1.2 # The repl doesn't work properly in 0.1.3

Now you have access to the oppo command. To enter the repl:

or

To compile a file:

oppo -c /path/to/file.oppo

You can also specify an output file:

oppo -o /path/to/file.js -c /path/to/file.oppo

In the previous command, if you have uglify-js2 installed globally, it will prettify the resulting javascript. You could pass the -C switch to have it compress your code instead.

To run a file:

Since oppo is a lisp, it takes on the basic semantics of a lisp. Oppo isn't dissimilar to scheme or clojure, so if you want to get a feel for the basic semantics of lisp, there's plenty of code out there to look at.

Here are some specifics about the way oppo is parsed:

"whatever". If you need to escape a double-quote, you can use \".

Oppo accepts most characters as valid symbols. Symbols can't start with a number or any of the following sequences: #, ", ', \``, ,, ,@, .`. Symbols can't contain any kind of whitespace. Anything else on the US keyboard is fair game.

Lists are code. Oppo code is primarily a tree of lists. All lists are executable. The basic way to make a list is to put space-separated items in parenthesis:

(puts "I" "am" "a" "list")

Since lists are executable, this will call the puts macro, which will log the rest of the items in the list to the console. If you don't want your list to be executed you can quote it or use a literal array:

'(1 2 3) ;; Won't try to call this as a function
#[1 2 3] ;; Same result

Oppo only thinks of objects as data and never tries to execute an object. Objects are made like this:

You can do some interesting things with oppo objects that you can't do in javascript (at least not as easily). For example, keys can be variables in the same way their values can:

(def key 'asdf)
(def value 5)
#{key value} ;; -> #{asdf 5}

Oppo uses the lambda macro to generate functions. There is also a reader macro #(...) which acts as a shorthand for the lambda macro. You can also define a function with the def macro:

(lambda (a b) (+ a b))

#(+ #1 #2) ;; #1 and #2 access the 0th and 1st arguments respectively

(def (add-a-b a b)
  (+ a b))

Following is a list of macros, functions and variables available to the oppo programmer. Entries take the format of <module>::<item-name>. The core module is automatically available, so you don't have to use the module prefix in that case. As an example, you can call core::str by simply invoking str (unless you have replaced str in your current module or in an active local scope).


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.3