User loginNavigation |
Prototyping a new language with HaskellHi all! I'm prototyping a new language with Haskell. Once I get the semantics right, I'll probably implement it more efficiently with straight C++ and LLVM. I hope to have something interactive soon. Here's the overview - Luna is intended to expose functional, object-oriented, and most importantly, 'language-oriented' programming paradigms in one simple and machine-efficient language. It has optional dynamic binding. The 'language orientation' paradigm is what makes the optional dynamic binding so important. Luna is general purpose. It has two syntaxes - sexp and meta, with the latter being used by default and being translated to sexp for macro processing. Macro processing is what makes the direct translation to sexp so important. ---- Syntaxes - Here's the sexp syntax (which is admittedly not super pretty) - ;; line comment {function {fibFast n} {if {less n 2} n {fibUp n 2 1 0}}} {function {fibUp max count x y} {if {equal max count} {add x y} {fibUp max {add count 1} {add x y} x}}} {function {factorial n} {if {lessEqual n 1} 1 {mul n {factorial {subtr n 1}}}}} {add 5 {mul 4 2}} {mul 5 {add 4 2}} {add 5 {abs {mul 4 2}}} {add 1 {add v1 {dot v2 v3}}} {assoc y x} ;; association list lookup {tuple {1 2 3}} Here's the meta syntax that maps one-to-one and is usable interchangeably with sexp syntax. It is column-sensitive once the colon is introduced. Meta syntax is transformed to sexp syntax before macro processing - ;; line comment function: fibFast(n) if: n < 2 n fibUp(n 2 1 0) function: fibUp(max count x y) if: max = count x + y fibUp(max count + 1 x + y x) function: factorial(n) if: n <= 1 1 n * factorial(n - 1) 4 * 2 + 5 +(4 2) * 5 abs(4 * 2) + 5 dot(v2 v3) + v1 + 1 x[y] 1; 2; 3 ---- All symbol resolution in the lexical scope of 'static' will be resolved statically. All resolution in the 'dynamic' scope will be resolved dynamically. The default scope when none is specified is 'static'. static: function: fibFast(n) if: n < 2 n fibUp(n 2 1 0) dynamic: function: fibUp(max count x y) if: max = count x + y fibUp(max count + 1 x + y x) ---- This is an overview of the definition functions - [listed in order of likely implementation] val: x(7) y(5) expression ;; bind immutable value(s) over an expression var: x(7) y(5) expression ;; bind mutable variable(s) over an expression vlz: x(1 + 1) expression ;; bind an expression to a name over another expression function: fn(x y) expression ;; declare a function lambda... ;; create a lambda macro... ;; define a lisp-style macro class... ;; class like in CLOS data... ;; an algebraic data type alias... ;; a type alias ---- Type inference - Types will be inferred where not specified. The type inference for the prototype will use the Hindley-Milner algorithm. Type inference algorithm will be the same for symbols resolved at compile-time with static binding as those resolved at run-time with dynamic binding. ---- Miscellanea - ---- So, anyways, that's the design so far. I ultimately hope I can get C-style programmers to consider using it. Edit: Updated to current design. By bryanedds at 2010-12-20 05:29 | LtU Forum | previous forum topic | next forum topic | other blogs | 8269 reads
|
Browse archives
Active forum topics |
Recent comments
27 weeks 1 day ago
27 weeks 2 days ago
27 weeks 2 days ago
49 weeks 3 days ago
1 year 1 week ago
1 year 3 weeks ago
1 year 3 weeks ago
1 year 5 weeks ago
1 year 10 weeks ago
1 year 10 weeks ago