š¾ Archived View for idiomdrottning.org āŗ brev captured on 2023-04-19 at 23:19:07. Gemini links have been rewritten to link to archived content
ā¬ ļø Previous capture (2023-03-20)
ā”ļø Next capture (2023-12-28)
-=-=-=-=-=-=-
Sometimes I do think of brev as a programming language.
Itās a maximalist Lisp derived from Scheme, with focus on implicitness, do-what-I-mean, magic, metaprogramming, expressiveness, batteries, brevity, and lack of weird grawlix ("$#{}[]+%%:;").
Here is hello world:
(print "Hello world!")
Thatās it. Thatās the whole file.
Here is hello world with extra steps:
;; Defines frob, a function that conses the first vowel and the first ;; two non vowels onto the rest (define (frob (v . vowels) (o1 o2 . others)) (cons* v o1 o2 (frob vowels others))) ;; Defines a version of frob that when there are no vowels, just ;; return the other stuff (define (frob '() end) end) ;; From the end: ;; In the string "pp wrpp", replace the last p with d and the rest ;; with l, into "ll wrld!" ;; Sort the string "oeo" into "eoo" ;; Pass those two strings as if they were lists, first passing them ;; through frob and then through an anonymous function that conses H ;; onto it ;; Then print it (print ((as-list (c cons #\H) frob) (sort "oeo") (strse "pp wrpp!" (only last "p") "d" "p" "l"))
Again, thatās the whole file.
Other times, I donāt think of it as a programming language. Because it wouldnāt exist if it werenāt for Chicken Scheme and all the hard work those developers have made over the last twenty years and hopefully many more to come.
Thatās why brevās programs compile into Chicken Scheme programs, brevās libraries compile into Chicken Scheme libraries, and any of brevās facilities and magics are usable from Chicken Scheme via extensions.
Thatās also why brev was so easy to makeāitās just a bunch of extensions, most of which already existed, and a way to automatically import them since Iām lazy and hate boilerplate.
Scheme is a beautiful minimalist language, the barest of building blocks that can make anything.
So letās make anything.
I just want to sand down every edge. Iām sick of boilerplate and of re-typing things that the compiler should do.
In other words, I love anaphora, clojurian, miscmacros and similar. I sometimes wish I could use a language where all that stuff was just built-in right away.
Hence brev.
It depends on and reexports the following extensions as is:
From sxml-transports it reexports pre-post-order* and pre-post-order-splice*, from sxpath it rexeports the eponymous sxpath procedure, and from bi-combinators it reexports the exceptionally useful bi-each combinator.
From uri-common it reexports everything but from some (not all!) of the procedures it removes āuri-ā or ā-uriā from the name, as follows:
(rename uri-common (uri-reference reference) (absolute-uri absolute) (uri-path path) (uri-query query) (uri-fragment fragment) (uri-host host) (uri-reference? reference?) (absolute-uri? absolute?) (uri-path-absolute? path-absolute?) (uri-path-relative? path-relative?) (uri-relative-to relative-to) (uri-relative-from relative-from))
From srfi-1, to prevent collisions with sequences, it adds a -list suffix to filter, take-while, drop-while and span.
From sequences, in order to match srfi-1, it renames take and drop to take-while and drop-while respectively, and split to span. It also changes the semantics of filter to have both a triadic variant (like the upstream sequences egg) and a biadic variant (to match srfi-1). It removes is? and empty? in favor of the ones from brev-separate.
This egg also contains the mdg extension (short for āmatch define genericsā), which imports define-dx from match-generics and renames it define, so you can have the fanciest define of all time.
The fanciest define of all time
Itās a separate extension to work around a since-fixed bug in older versions of Chicken. Itāll become oart of brev instead (and the mdg extension deprecated) when the new Chicken becomes part of Debian stable.
.brev files are scheme files that have an implicit (import brev mdg) at the start of them.
On zsh and bash you can use csc -prologue <(echo ā(import brev mdg)ā) your-file-name.brev
to compile them.
On POSIX, you can use this shell script: #!/bin/sh echo ā(import brev mdg)ā > /tmp/brev-prol.scm csc -prologue /tmp/brev-prol.scm ā$@ā
This is provided in the egg repo with the name brev. It also passes through any other flags you add, like -O3 or whatever. brev -O3 your-file-name.brev
This is great for quick little apps and pocs and explorations.
If you are making modules (especially if you are making eggs), instead please just make them as normal .scm files that import only the modules they actually need, including brev-separate if needed. There is a brev2scm program included that helps you do that.
Just add (add-to-list āauto-mode-alist ā(ā\.brev$ā . scheme-mode))
in your init file to load .brev files with scheme-mode. (Or change to taste if you like other modes for your scheming.)
Brev is just a meta package so itās up to the license of stuff it links in. The meta-package itself is just public domain. The new stuff in brev-separate is BSD 1-clause.
Subscribe: brev-dev+subscribe@zebra.idiomdrottning.org