* wisp literal array syntax for Guile, a good idea?
@ 2017-11-12 18:34 Arne Babenhauserheide
2017-11-12 21:20 ` Matt Wette
0 siblings, 1 reply; 5+ messages in thread
From: Arne Babenhauserheide @ 2017-11-12 18:34 UTC (permalink / raw)
To: guile-user-mXXj517/zsQ, readable-discuss
[-- Attachment #1.1: Type: text/plain, Size: 3929 bytes --]
Hi,
Wisp¹ as general syntax is pretty much done. The releases this year only
provided bug fixes and additional examples. A procedure definition looks
like this:
define : hello who
format #f "Hello ~a!\n"
. who
From experience with building tools with Wisp² I am pretty happy with
its syntax; it feels like a sweet spot between minimal syntax-overhead
and producing easily readable code (leaning a bit more towards minimal
syntax-overhead than readable/sweet).
But there is one Guile-specific feature where it is lacking: When
defining a procedure in Guile, you can add properties by creating a
literal array as line — or as second line if the first line is a literal
string that then serves as documentation. This can be used to define
tests.³ Then a full fledged Hello World! looks like this:
define : hello who
. "Say hello to WHO"
. #((tests
(test-equal "Hello World!\n"
(hello "World"))))
format #f "Hello ~a!\n"
. who
And this is all and nice, but it prevents using indentation-based syntax
for the properties. This would be no problem if I could simply make an
array with non-literal syntax — i.e. (list->array (list (list tests
(list test-eqv ...)))) — but Guile property syntax requires a literal
array.
Therefore I created a reader-extension⁴ which allows creating literal
arrays with indentation-based syntax using the hash-extension ##:
define : hello who
. "Say hello to WHO"
##
tests
test-equal "Hello World!\n"
hello "World"
format #f "Hello ~a!\n"
. who
To my eyes this looks reasonably nice, and it allows using arbitrary
arrays. It uses the conventional #-extension common to Scheme which
avoids adding more constructs, and internally it just passes
## a b c
to the wisp paren-restructuring code as
(#\# a b c)
which then becomes
#(a b c)
as used in similar fashion for the other special paren-prefixes
("'" "," "#'", ...).
But it feels strange to add specialized syntax here. I would rather want
something more general — something which does not feel like opening a
can of worms of more and more syntax elements which could crop in. It
feels like straying from the path of simplicity.
Therefore I’d like to ask you for comments. Do you have ideas how this
could be made more elegant? Or is this intrinsic complexity of the
Scheme or Guile literal array prefix (and the other paren-prefixes)
which I cannot escape with wisp?
Best wishes,
Arne
¹: Wisp website: http://www.draketo.de/english/wisp
²: Wisp examples (tools with wisp):
https://bitbucket.org/ArneBab/wisp/src/e80659fcc896ab04fbcd0a2d78e0dc25fef474a0/examples/
³: This doctest syntax is built on SRFI-64 and implemented in
<https://bitbucket.org/ArneBab/wisp/src/e80659fcc896ab04fbcd0a2d78e0dc25fef474a0/examples/doctests.w>
and
<https://bitbucket.org/ArneBab/wisp/src/e80659fcc896ab04fbcd0a2d78e0dc25fef474a0/examples/doctests.scm>
⁴: The code for the reader extension consists of a single line in the reader:
read-hash-extend #\# : λ (chr port) #\#
<https://bitbucket.org/ArneBab/wisp/src/e80659fcc896ab04fbcd0a2d78e0dc25fef474a0/wisp-reader.w#wisp-reader.w-39>
eight lines in the clean parser (currently mostly a hack)
<https://bitbucket.org/ArneBab/wisp/src/e80659fcc896ab04fbcd0a2d78e0dc25fef474a0/wisp-scheme.w#wisp-scheme.w-689>
and some special cases in the bootstrap parser and wisp->lisp converter which operates on bare strings
<https://bitbucket.org/ArneBab/wisp/src/e80659fcc896ab04fbcd0a2d78e0dc25fef474a0/wisp-guile.w#wisp-guile.w-513>
<https://bitbucket.org/ArneBab/wisp/src/e80659fcc896ab04fbcd0a2d78e0dc25fef474a0/wisp-guile.w#wisp-guile.w-567>
--
Unpolitisch sein
heißt politisch sein
ohne es zu merken
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
[-- Attachment #2: Type: text/plain, Size: 202 bytes --]
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
[-- Attachment #3: Type: text/plain, Size: 207 bytes --]
_______________________________________________
Readable-discuss mailing list
Readable-discuss-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/readable-discuss
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: wisp literal array syntax for Guile, a good idea?
2017-11-12 18:34 wisp literal array syntax for Guile, a good idea? Arne Babenhauserheide
@ 2017-11-12 21:20 ` Matt Wette
[not found] ` <098670CE-873B-4DCC-A111-A88044861BBD-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Matt Wette @ 2017-11-12 21:20 UTC (permalink / raw)
To: Arne Babenhauserheide; +Cc: guile-user, readable-discuss
> On Nov 12, 2017, at 10:34 AM, Arne Babenhauserheide <arne_bab@web.de> wrote:
>
> Hi,
>
> Wisp¹ as general syntax is pretty much done. The releases this year only
> provided bug fixes and additional examples. A procedure definition looks
> like this:
>
> define : hello who
> format #f "Hello ~a!\n"
> . who
>
> From experience with building tools with Wisp² I am pretty happy with
> its syntax; it feels like a sweet spot between minimal syntax-overhead
> and producing easily readable code (leaning a bit more towards minimal
> syntax-overhead than readable/sweet).
>
> But there is one Guile-specific feature where it is lacking: When
> defining a procedure in Guile, you can add properties by creating a
> literal array as line — or as second line if the first line is a literal
> string that then serves as documentation. This can be used to define
> tests.³ Then a full fledged Hello World! looks like this:
>
> define : hello who
> . "Say hello to WHO"
> . #((tests
> (test-equal "Hello World!\n"
> (hello "World"))))
> format #f "Hello ~a!\n"
> . who
Do you have a syntax for vector literals? If not, why can't you just write
define : hello who
"Say hello to WHO"
vector : tests
test-equal "hello World"
. hello "World
format #f "Hello ~a!\n"
. who
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: wisp literal array syntax for Guile, a good idea?
[not found] ` <098670CE-873B-4DCC-A111-A88044861BBD-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2017-11-12 22:38 ` Arne Babenhauserheide
[not found] ` <87k1yvglih.fsf-S0/GAf8tV78@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Arne Babenhauserheide @ 2017-11-12 22:38 UTC (permalink / raw)
To: Matt Wette; +Cc: guile-user-mXXj517/zsQ, readable-discuss
[-- Attachment #1.1: Type: text/plain, Size: 938 bytes --]
Matt Wette <matt.wette-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
> Do you have a syntax for vector literals? If not, why can't you just write
I don’t, but while
(vector '(a b))
⇒ #((a b))
(define (f)
(vector '(a b)) #f)
(procedure-properties f)
⇒ ((name . f))
But
(define (f)
#((a b)) #f)
(procedure-properties f)
⇒ ((name . f) (a b))
So this is a purely Guile-specific issue: I want Guile to recognize the
vector as function-property. If it recognized (vector ...), I could use
the simple syntax
define : hello who
. "Say hello to WHO"
vector
' tests
test-equal "Hello World!\n"
hello "World"
format #f "Hello ~a!\n"
. who
(this would be my preferred approach, but I did not find any way to get
this working)
Best wishes,
Arne
--
Unpolitisch sein
heißt politisch sein
ohne es zu merken
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
[-- Attachment #2: Type: text/plain, Size: 202 bytes --]
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
[-- Attachment #3: Type: text/plain, Size: 207 bytes --]
_______________________________________________
Readable-discuss mailing list
Readable-discuss-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/readable-discuss
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: wisp literal array syntax for Guile, a good idea?
[not found] ` <87k1yvglih.fsf-S0/GAf8tV78@public.gmane.org>
@ 2017-12-12 22:58 ` Alan Manuel Gloria
[not found] ` <CAF+kUQW-m2=OPB1Fjf9_r0ftBj5d_c4NSag-r+HfFtkLEvoomw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Alan Manuel Gloria @ 2017-12-12 22:58 UTC (permalink / raw)
To: Arne Babenhauserheide
Cc: guile-user-mXXj517/zsQ, readable-discuss, Matt Wette
[-- Attachment #1.1: Type: text/plain, Size: 1926 bytes --]
This is arguably NOT a Guile-specific issue, but rather a general issue.
Clojure uses its array syntax for parts of its syntax, for example.
The ## seems OK, but how about just plain # ?
So like (using only (read) and not (eval (read))):
' a b
=> (quote (a b))
'(a b)
=> (quote (a b))
# a b
=> #(a b)
#(a b)
=> #(a b)
Sincerely,
AmkG
On Mon, Nov 13, 2017 at 6:38 AM, Arne Babenhauserheide <arne_bab-S0/GAf8tV78@public.gmane.org>
wrote:
>
> Matt Wette <matt.wette-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
>
> > Do you have a syntax for vector literals? If not, why can't you just
> write
>
> I don’t, but while
>
> (vector '(a b))
> ⇒ #((a b))
>
> (define (f)
> (vector '(a b)) #f)
> (procedure-properties f)
> ⇒ ((name . f))
>
> But
> (define (f)
> #((a b)) #f)
> (procedure-properties f)
> ⇒ ((name . f) (a b))
>
> So this is a purely Guile-specific issue: I want Guile to recognize the
> vector as function-property. If it recognized (vector ...), I could use
> the simple syntax
>
> define : hello who
> . "Say hello to WHO"
> vector
> ' tests
> test-equal "Hello World!\n"
> hello "World"
> format #f "Hello ~a!\n"
> . who
>
> (this would be my preferred approach, but I did not find any way to get
> this working)
>
> Best wishes,
> Arne
> --
> Unpolitisch sein
> heißt politisch sein
> ohne es zu merken
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Readable-discuss mailing list
> Readable-discuss-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/readable-discuss
>
>
[-- Attachment #1.2: Type: text/html, Size: 3169 bytes --]
[-- Attachment #2: Type: text/plain, Size: 202 bytes --]
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
[-- Attachment #3: Type: text/plain, Size: 207 bytes --]
_______________________________________________
Readable-discuss mailing list
Readable-discuss-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/readable-discuss
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: wisp literal array syntax for Guile, a good idea?
[not found] ` <CAF+kUQW-m2=OPB1Fjf9_r0ftBj5d_c4NSag-r+HfFtkLEvoomw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2017-12-13 17:29 ` Arne Babenhauserheide
0 siblings, 0 replies; 5+ messages in thread
From: Arne Babenhauserheide @ 2017-12-13 17:29 UTC (permalink / raw)
To: Alan Manuel Gloria; +Cc: guile-user-mXXj517/zsQ, readable-discuss, Matt Wette
[-- Attachment #1.1: Type: text/plain, Size: 1140 bytes --]
Hi Alan,
Thank you for your answer!
Alan Manuel Gloria <almkglor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
> This is arguably NOT a Guile-specific issue, but rather a general issue.
> Clojure uses its array syntax for parts of its syntax, for example.
>
> The ## seems OK, but how about just plain # ?
That’s part of why it’s Guile specific: I cannot use the plain #,
because that’s the prefix for symbols and illegal syntax for read. I
don’t see a way to do this as simple reader addition.
> So like (using only (read) and not (eval (read))):
>
> ' a b
> => (quote (a b))
> '(a b)
> => (quote (a b))
> # a b
> => #(a b)
> #(a b)
> => #(a b)
I’d like to do it that way, but from what I can tell, doing that would
mean that I have to special-case all special syntax reading, while with
the ## I can harness regular symbol reading in Guile.
The # is the prefix for all kinds of special elements (i.e. #' #, #,@)
and I’m not sure it’s a good idea to take the symbol itself for a given
feature.
Best wishes,
Arne
--
Unpolitisch sein
heißt politisch sein
ohne es zu merken
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
[-- Attachment #2: Type: text/plain, Size: 202 bytes --]
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
[-- Attachment #3: Type: text/plain, Size: 207 bytes --]
_______________________________________________
Readable-discuss mailing list
Readable-discuss-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/readable-discuss
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-12-13 17:29 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-12 18:34 wisp literal array syntax for Guile, a good idea? Arne Babenhauserheide
2017-11-12 21:20 ` Matt Wette
[not found] ` <098670CE-873B-4DCC-A111-A88044861BBD-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-11-12 22:38 ` Arne Babenhauserheide
[not found] ` <87k1yvglih.fsf-S0/GAf8tV78@public.gmane.org>
2017-12-12 22:58 ` Alan Manuel Gloria
[not found] ` <CAF+kUQW-m2=OPB1Fjf9_r0ftBj5d_c4NSag-r+HfFtkLEvoomw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-12-13 17:29 ` Arne Babenhauserheide
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).