[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] add SRFI-119 / language/wisp to Guile? (new patch with more
From: |
Dr. Arne Babenhauserheide |
Subject: |
Re: [PATCH] add SRFI-119 / language/wisp to Guile? (new patch with more tests, squashed) |
Date: |
Thu, 13 Jun 2024 22:29:41 +0200 |
Hi,
I realized that I did not actually send the reply to the list.
Damien Mattei <damien.mattei@gmail.com> writes:
> where is the doc of Wisp? i did not yet install it, as i understand it will
> be included in next release of Guile?
The documentation is either in the SRFI or on the wisp website:
- https://srfi.schemers.org/srfi-119/srfi-119.html
- https://www.draketo.de/software/wisp
- https://www.draketo.de/software/wisp#after-updates
If that’s useful, I’ll gladly send a patch to add it to the Guile
reference manual.
> what is the exact meaning of : and . ?
These control how parentheses are added to turn wisp with indentation
into regular Scheme.
In general every non-empty line opens a paren-pair which closes before
the next line with lower or equal indentation:
hello world
is
(hello world)
hello
append world "!"
newline
is
(hello
(append world "!"))
(newline)
If you start the line with ., it does not start with a paren.
+ 1
. 2 3
is
(+ 1
2 3)
If you need double-parentheses, you mark one line with :
(only whitespace, one :, and comments)
let
:
a 1
b 2
+ a b
is
(let
(
(a 1)
(b 2))
(+ a b))
If : is in a line with other non-whitespace non-comments, it starts an
inline paren-pair that ends at the end of the line.
define : hello world
display "Hello "
display world
is
(define (hello world)
(display "Hello ")
(display world))
That can also make let look nicer:
let
: a 1
b 2
+ a b
is
(let
((a 1)
(b 2))
(+ a b))
> any simple examples?
display "Hello World!" ↦ (display "Hello World!")
define : factorial n ↦ (define (factorial n)
if : zero? n (if (zero? n)
. 1 1
* n : factorial {n - 1} (* n (factorial {n - 1}))))
> is it possible in Wisp to use normal scheme expression? can we mix the
> scheme code and wisp code?
you can use normal scheme in wisp. Within parentheses,
indentation-processing is then disabled (so you can simply copy-paste
scheme into wisp).
For example this is valid Wisp:
define (hello world)
display (string-append "Hello "
world "!")
newline
hello "Wisp"
The reason is that the goal of wisp is to live within a Scheme world,
not replace Scheme. So the design assumes that the dominant language
will be Scheme.
The hardest part I see with such embedding is to stay simple. Every
syntax adaption is a risk.
That’s the main reason why Wisp split off from readable (srfi-110):
readable added more and more special cases and lost the simplicity I see
as one of the big strength of Scheme.
Wisp in contrast is intentionally limited to the minimum set of
additions needed to create a usable indentation-based Scheme.
For example the dot-prefix (.) does not take away existing syntax
because the dot is used in a position where it is illegal in regular
Scheme: (. 1 2 3) is a syntax error. But in many Schemes, (= 1 (. 1)).
Best wishes,
Arne
--
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de
signature.asc
Description: PGP signature