Languages Features Creators CSV Resources Challenges Add Language
GitHub icon

Bel

Bel - Programming language

< >

Bel is a programming language created in 2019 by Paul Graham.

#596on PLDB 4Years Old 0Books
0Papers


Example from the web:
; Bel in Bel. 9 October 2019, 9:14 GMT (def no (x) (id x nil)) (def atom (x) (no (id (type x) 'pair))) (def all (f xs) (if (no xs) t (f (car xs)) (all f (cdr xs)) nil)) (def some (f xs) (if (no xs) nil (f (car xs)) xs (some f (cdr xs)))) (def reduce (f xs) (if (no (cdr xs)) (car xs) (f (car xs) (reduce f (cdr xs))))) (def cons args (reduce join args)) (def append args (if (no (cdr args)) (car args) (no (car args)) (apply append (cdr args)) (cons (car (car args)) (apply append (cdr (car args)) (cdr args)))))

Language features

Feature Supported Token Example
Macros
; A macro is essentially a function that generates code. I would have 
; liked the first example of a macro to be something simpler, but fn
; is the one we need first. So I'll introduce macros using a simpler 
; macro that isn't part of Bel, then explain fn.
; Here is a very simple macro:
(mac nilwith (x)
  (list 'cons nil x))
Strings
(\h \e \l \l \o)
; can also be represented as
"hello"
Booleans
; The symbol nil represents falsity as well as the empty list.
; The symbol t is the default representation for truth, but any object other than nil also counts as true. 
Functions
(fn (x) (+ x 1))
Expressions
(+ 1 2)
Streams
Lists
; here is a list of a, b, and c:
(a . (b . (c . nil)))
; can be written as
(a b c)
Characters
\p
; Characters that aren't letters may have longer names. For example the bell character, after which Bel is named, is
\bel
hasSymbols
foo
Pairs
(foo . bar)
Print() Debugging prn
Comments
; A comment
Line Comments ;
; A comment
Semantic Indentation X
Case Insensitive Identifiers X
blitzplus.html · bel.html · sql-92.html

View source

- Build the next great programming language · Search · Day 213 · About · Blog · Acknowledgements · Traffic · Traffic Today · GitHub · feedback@pldb.com