I looked at your python code:
1. It seems that it currently doesn't handle ":" in the middle of a line, yet.
2. It seems that multiple ": " at the start of each line are ignored,
and only the last one is used. So the following is possibly (?)
valid:
define foo(bar)
: cond
: : meow?(bar)
: : : cat bar
: : woof?(bar)
: : : dog bar
: : else
: : : error 'foo "error!"
--
About ":"
How about this semantic instead?
":" introduces a (, and a promise to add ) at the end of that line.
It is like a limited $, except that $ will not wrap a single item on
the line (: will) and $ can cross the line end.
This localizes ":", meaning that we can use it this way:
define : add-if-all-numbers lst
call/cc
lambda : exit
let loop
\\
lst lst
sum 0
if : null? lst
sum
if : not : number? : car lst
exit #f
loop : cdr lst
+ sum : car lst
This seems to be a lot more readable, since the previous rule for ":"
*required* a lot more horizontal space; this time, it's optional (see
the arguments to loop on the last two lines for a good use of it).
--
When crossing line boundaries, $ does a better job than your current
":" idea, because it doesn't require keeping track of column
positions. So I think $ should keep that job, and only use : for the
limited case where it's useful to only put it to the end of the line.
For example, say I'm debugging a long and boring stream function
(using SRFI-41 streams). So I develop a "probe" function like so:
define-stream probe(x) $ cond
stream-pair?(x) $ begin
display (stream-car x) \\ newline()
stream-cons
stream-car x
probe $ stream-cdr x
else $ stream-null
And I apply it to my stream code like so:
define-stream stream-map(f s) $ probe $ cond
stream-pair?(x) $ stream-cons
f $ stream-car x
stream-map f $ stream-cdr x
else $ stream-null
In the first place, ":" can't support the shown cond-pattern. So
without $, it would look like (without probe):
define-stream stream-map(f s)
cond
stream-pair?(x) : stream-cons
f : stream-car x
stream-map f : stream-cdr x
else : stream-null
With probe:
define-stream stream-map(f s)
probe
cond
stream-pair?(x) : stream-cons
f : stream-car x
stream-map f : stream-cdr x
else : stream-null
So, just to probe my code, I need an extra indentation. With $, I
don't need the extra indentation.
":" can't be used here (using your current idea for ":"), since it
would require indenting even more than just using a separate line
would.
"$" is surprisingly versatile.
-----
A new synthesis?
Perhaps we can *keep* GROUP/SPLIT \\, SUBLIST $, and COLLECTINGLIST <*
*>, use the EXTENDPERIOD . a b, and add the new LINELIST :
Then we can do something like:
<* define-library \\ (amkg foo)
export
. cat dog meow
. whatever woof arf
import
(scheme base)
<* begin
define : cat x
let : : y {x + 1}
meow x y
define : dog x
woof $ meow {x - 1} {x + 2}
...
*>;begin
*>;define-library
what you think?
------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
Readable-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/readable-discuss