Jedi Programming Language Report

Verified

Added on  2019/09/26

|4
|693
|248
Report
AI Summary
This report provides a comprehensive overview of the experimental programming language, Jedi. It details the language's core features, including support for lambdas, closures, static scoping, eager and lazy execution, blocks, variables, and objects. The report also explains Jedi's read-execute-print loop (REPL) and demonstrates its functionality through examples. A significant portion of the report is dedicated to explaining the architecture of Jedi, including its three interdependent packages: Jedi Expressions, Jedi Context, and Jedi Values. Each package's role and functionality are described in detail, along with explanations of concepts like eager and lazy execution, special forms, declarations, and the handling of exceptions. The report also clarifies the role of the console singleton, the global environment, and the ALU singleton in the execution of Jedi programs. Finally, it discusses the different types of values in Jedi, including closures, variables, stores, notifications, and literals.
Document Page
Jedi
Jedi is an experimental language that supports many features found in modern
programming languages:
Lambdas, closures, and static scoping
Eager and lazy execution
Blocks
Variables
Objects
Dynamic type checking
A Jedi Session
Jedi's read-execute-print loop (REPL) reads an expression string entered by the user,
parses it into an expression object, executes the object, then prints the resulting value:
-> 2 + 3 * 5
17
-> 2.0 + 3 * 5
17.0
-> def pi = 3.14
ok
-> pi
3.14
-> def square = lambda(x) x * x
ok
-> square(7)
49
-> def area = lambda(r) pi * square(r)
ok
-> area(10)
314.0
-> pi < 3 && z < 10
false
-> z
Undefined identifier: z
-> if (pi < 3) x else 100
100
-> x
Undefined identifier: x
-> def count = var(0)
ok
-> count
Variable(0.0)
-> [count]
0.0
-> count = [count] + 1
done
-> [count]
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
1.0
-> while([count] < 100) count = [count] + 1
done
-> [count]
100.0
-> write("Hello world")
Hello world
done
-> quit
bye
Notes:
Multiplication has higher precedence than addition
Conjunction (&&) and disjunction (||) use short-circuit execution (a form of lazy
execution)
Conditionals (if) use conditional execution (another form of lazy execution)
Jedi Packages
Jedi consists of three interdependent packages:
Jedi Expressions
Notes:
Document Page
Executing a Jedi expression requires an environment (i.e. hash tables) and
produces a value.
FunCalls (i.e., function calls or applications) use eager execution. The execute all
of their operands (i.e., inputs) even if they don't need to.
Special forms use custom execution algorithms such a short-circuit or conditional
execution.
Declarations (i.e., definitions) are special forms that add bindings (i.e., name-
value associations) to the environment.
Identifiers are names of values. To execute an identifier we simply look it up in
the environment.
The value of a literal is literally itself.
Jedi Context
Executing a program requires a computer. A computer provides all of the needed
circuitry.
Notes:
The console singleton provides the read-execute-print loop, the global
environment, and a main method.
The global environment is a hash table that associates identifiers to values. (E.g.,
pi = 3.14.) Initially it is empty. Executing declarations at the console's prompt
will add bindings to the global environment.
Document Page
The console requires parsers to parse expression strings into expression objects
(i.e., objects having the expression trait defined above).
The console must be able to handle the different kinds of exceptions execution
might throw.
The ALU singleton provides Jedi's built-in functions for doing arithmetic, logic,
and simple I/O.
Jedi Values
Notes:
Executing an expression relative to an environment produces a value.
Closures are functions that remember their defining environments.
A variable is a value that contains another value.
A store is a buffer that contains values.
Notifications are acknowledgements (e.g., "ok", "done", "unspecified") returned
by expressions that produce side effects such as updating a variable, store, or
environment.
Literals are values and expressions. The value of a literal is itself.
Literals encapsulate Scala values such as Int, Double, String, and Boolean.
chevron_up_icon
1 out of 4
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]