|
|
||
|---|---|---|
| doc | ||
| examples | ||
| src | ||
| COPYING | ||
| README.org | ||
README.org
Guise
Overview
Guise is a concatenative, functional, statically-typed, stack-based language with S-expression syntax, implemented in Guile.
It combines:
- Joy's pure concatenative semantics
- Factor's practical stack language design
- Scheme's S-expression syntax
- ML's algebraic data types and static type inference
Key Features
Stack-Based Evaluation
All computation happens through stack manipulation. Operations execute left-to-right, consuming and producing values on the stack.
First-Class Quotations
Code blocks are first-class values that can be passed around and executed with call.
Algebraic Data Types
Define product types (tuples) and sum types (tagged unions) with auto-generated constructors and accessors.
Static Type Inference
Type signatures are checked at compile time, with full type inference for stack effects.
Module System
Organize code with modules, imports, and public/private visibility control.
Quick Start
Running the REPL
GUILE_LOAD_PATH=src GUILE_AUTO_COMPILE=0 guile --language=guise
Note: GUILE_AUTO_COMPILE=0 prevents Guile from trying to compile Scheme runtime modules using the Guise compiler.
Running Examples
GUILE_LOAD_PATH=src GUILE_AUTO_COMPILE=0 guile --language=guise < examples/basic.guise
Your First Guise Program
;; Stack operations - left to right evaluation
(5 3 +) ; Push 5, push 3, add → 8
(dup *) ; Duplicate top, multiply → square
;; Define a word (function) with stack effect signature
(define square (number -> number)
(dup *))
(5 square) ; → 25
;; Quotations are first-class code blocks
'(dup *) ; Push quotation onto stack
(5 '(dup *) call) ; Execute quotation → 25
;; Higher-order functions
(define twice ('a (quot ('a -> 'a)) -> 'a)
(dup call call))
(5 'square twice) ; → 625 (5 squared twice)
Examples
See the examples/ directory:
basic.guise- Basic arithmetic and stack operationsquotations.guise- Higher-order functions with quotationsnumbers.guise- Number type hierarchy examplestuples.guise- Tuple construction and operations
Documentation
Language Reference
- BNF Grammar - Formal syntax specification
Contributing
Guise is in active development. Contributions, feedback, and ideas are welcome!