Hi all,
continuing on alias tokens for collecting lists.
Two aspects have made my feelings stronger that I'd actually like {* and
*}: A) As noted before, users usually know how to key them in. B) My
emacs will make it easy to skip over the block in most editing modes.
To get a feeling what it would take I go my hands dirty. Resulting diff
below. Note that this code is a dirty hack by now. Where
`my-read-delimited-list` returns '<* I should probably attach source
info, shouldn't I? Let alone that I tend to believe that the token ought
to be generated more generic. Furthermore there should be a
configuration option to switch it off entirely as the other reader
features already have.
There is one more nice thing if the alias was actually to work correct:
one could drop two more characters from the special set the programmer
has to be aware of < and >.
So far there is only so much test coverage. But I have not yet managed
to write a test case which returns surprising results.
To my current knowledge there is actually only one user-visible change
besides {* *} becoming an alias for <* *>: the way one has to actually
get a symbol "star" read after a {: separate it by white space to avoid
it being taken as opening a collecting list. Is this actually all the
damage it did? What am I missing?
Best regards
/Jörg
----
--- /media/u/Arbeit/jfw/build/armhf/askemos/ball/mechanism/srfi/srfi-110.scm
2014-02-18 14:26:17.819821953 +0100
+++ srfi-110-ndbg.scm 2014-05-09 13:33:41.296085721 +0200
@@ -1634,9 +1634,19 @@
(my-read-delimited-list neoteric-read-nocomment #\] port)))
((char=? c #\{ )
(my-read-char port)
- (attach-sourceinfo pos
- (process-curly
- (my-read-delimited-list neoteric-read-nocomment #\} port))))
+ (let ((c (my-peek-char port)))
+ (if (eqv? c #\*)
+ (let ((e (underlying-read neoteric-read-nocomment port)))
+ (if (eq? e '*)
+ '<*
+ (attach-sourceinfo
+ pos
+ (process-curly
+ (cons e (my-read-delimited-list
neoteric-read-nocomment #\} port))))))
+ (attach-sourceinfo
+ pos
+ (process-curly
+ (my-read-delimited-list neoteric-read-nocomment #\}
port))))))
((my-char-whitespace? c)
(my-read-char port)
(neoteric-read-real port))
@@ -1759,14 +1769,20 @@
(let ((c (my-peek-char port)))
(let-splitter (results type expr)
(n-expr-or-scomment port)
- (if (eq? (car results) 'scomment)
+ (if (eq? type 'scomment)
results
(cond
((and (eq? expr sublist) (eqv? c sublist-char))
(list 'sublist-marker '()))
((and (eq? expr group-split) (eqv? c group-split-char))
(list 'group-split-marker '()))
- ((and (eq? expr '<*) (eqv? c #\<))
+ ((eq? expr '*)
+ (if (eqv? #\} (my-peek-char port))
+ (begin
+ (my-read-char port)
+ (list 'collecting-end '()))
+ results))
+ ((and (eq? expr '<*) (or (eqv? c #\{) (eqv? c #\<)))
(list 'collecting '()))
((and (eq? expr '*>) (eqv? c #\*))
(list 'collecting-end '()))
--- /media/u/Arbeit/jfw/build/armhf/askemos/ball/mechanism/srfi/srfi-110.scm 2014-02-18 14:26:17.819821953 +0100
+++ srfi-110-ndbg.scm 2014-05-09 13:33:41.296085721 +0200
@@ -1634,9 +1634,19 @@
(my-read-delimited-list neoteric-read-nocomment #\] port)))
((char=? c #\{ )
(my-read-char port)
- (attach-sourceinfo pos
- (process-curly
- (my-read-delimited-list neoteric-read-nocomment #\} port))))
+ (let ((c (my-peek-char port)))
+ (if (eqv? c #\*)
+ (let ((e (underlying-read neoteric-read-nocomment port)))
+ (if (eq? e '*)
+ '<*
+ (attach-sourceinfo
+ pos
+ (process-curly
+ (cons e (my-read-delimited-list neoteric-read-nocomment #\} port))))))
+ (attach-sourceinfo
+ pos
+ (process-curly
+ (my-read-delimited-list neoteric-read-nocomment #\} port))))))
((my-char-whitespace? c)
(my-read-char port)
(neoteric-read-real port))
@@ -1759,14 +1769,20 @@
(let ((c (my-peek-char port)))
(let-splitter (results type expr)
(n-expr-or-scomment port)
- (if (eq? (car results) 'scomment)
+ (if (eq? type 'scomment)
results
(cond
((and (eq? expr sublist) (eqv? c sublist-char))
(list 'sublist-marker '()))
((and (eq? expr group-split) (eqv? c group-split-char))
(list 'group-split-marker '()))
- ((and (eq? expr '<*) (eqv? c #\<))
+ ((eq? expr '*)
+ (if (eqv? #\} (my-peek-char port))
+ (begin
+ (my-read-char port)
+ (list 'collecting-end '()))
+ results))
+ ((and (eq? expr '<*) (or (eqv? c #\{) (eqv? c #\<)))
(list 'collecting '()))
((and (eq? expr '*>) (eqv? c #\*))
(list 'collecting-end '()))
------------------------------------------------------------------------------
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
• 3 signs your SCM is hindering your productivity
• Requirements for releasing software faster
• Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce
_______________________________________________
Readable-discuss mailing list
Readable-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/readable-discuss