Re: [Readable-discuss] noop patch - add type information
Am 17.11.2013 23:38, schrieb David A. Wheeler: On Sun, 17 Nov 2013 21:31:34 +0100, Jörg F. Wittenberger: In an attempt to better understand and document the source code I added type annotations (using the chicken's syntax and using chicken to verify it). I like this idea. In a few places this patch changes return values to intentionally return (values)... which is also okay by me. Unless anyone complains soon (Alan?), I plan to add it. It might be a bad idea to return no values instead of some undefined. Not sure, but I'd believe that notably chicken would do worse on returning no values instead of the fake value it returns for undefined returns. Also the patch introduces warnings that way. But nevertheless, I think the documentation it serves makes it worth. -- DreamFactory - Open Source REST JSON Services for HTML5 Native Apps OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access Free app hosting. Or install the open source package on any LAMP server. Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native! http://pubads.g.doubleclick.net/gampad/clk?id=63469471iu=/4140/ostg.clktrk ___ Readable-discuss mailing list Readable-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/readable-discuss
Re: [Readable-discuss] Fwd: Re: Supporting SRFI-110 in chicken (Joerg Wittenberger)
Am 17.11.2013 22:17, schrieb David A. Wheeler: On Sun, 17 Nov 2013 15:13:09 -0500, John Cowan co...@mercury.ccil.org wrote: I don't see any obvious way to do so, except with a weak-keyed hash table mapping ports to values. Unfortunately, weak-keyed hash tables are non-portable in the nature of things. I know. I'm currently thinking of implementing these settings as straight-up hash tables that map from ports to values. Those are, at least, efficient to look up, even if there are many ports. Ideally they'd be weak references, but I suspect most implementations don't constantly create new ports and pass them to readable. Well, BALL does. It finds many, many small expressions withing XML attributes when it produces wep pages. Those little scripts are feed to the reader. And if they do, they'll just slowly increase memory use.. not hugely. At least I would *not* bet a single cent on your slowly prediction here. There is a gimmick we could use. We could create a reset port function that *REMOVES* the entry from the hashtable. Then, on next use, it'd recreate the entries. That would be a clean interface, but work efficiently in a portable way. That would mean that systems would need to reset ports if they create huge numbers of them. Sadly, I don't see how to deal with that cleanly without weak references. I'm still not convinced. So far I did not understand why does this have to be port-specific in the first place. Maybe that would be the killer argument. Maybe not: at least in my case, I'd be *happy* to have a way to compile-time the feature away eventually, since I know these settings will not change. /Jörg -- DreamFactory - Open Source REST JSON Services for HTML5 Native Apps OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access Free app hosting. Or install the open source package on any LAMP server. Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native! http://pubads.g.doubleclick.net/gampad/clk?id=63469471iu=/4140/ostg.clktrk ___ Readable-discuss mailing list Readable-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/readable-discuss
Re: [Readable-discuss] noop patch - add type information
Am 18.11.2013 10:38, schrieb Jörg F. Wittenberger: Am 17.11.2013 23:38, schrieb David A. Wheeler: On Sun, 17 Nov 2013 21:31:34 +0100, Jörg F. Wittenberger: In an attempt to better understand and document the source code I added type annotations (using the chicken's syntax and using chicken to verify it). I like this idea. In a few places this patch changes return values to intentionally return (values)... which is also okay by me. Unless anyone complains soon (Alan?), I plan to add it. It might be a bad idea to return no values instead of some undefined. Not sure, but I'd believe that notably chicken would do worse on returning no values instead of the fake value it returns for undefined returns. Also the patch introduces warnings that way. Attached a slightly better version of the add types patch. This one replaces (values) with a (no-values) syntax from the compatibility layer and has those procedures, which used to return no values or undefined values type-annotated as returning undefined. --- kernel.scm.orig 2013-11-17 21:23:38.0 +0100 +++ kernel.scm 2013-11-18 12:04:32.0 +0100 @@ -176,6 +176,19 @@ (define-module (readable kernel))) (else )) +; Chicken compatible type annotations. Ignored on other platforms. +(cond-expand + (chicken + (define-type :reader-proc: (input-port - *)) + (define-type :reader-token: (pair symbol *)) + (define-type :reader-indent-token: (list string *)) + (define-syntax no-values (syntax-rules () ((_) (void + ) + (else + (define-syntax : (syntax-rules () ((_ . rest) #f))) + (define-syntax no-values (syntax-rules () ((_) (if #f #t + )) + ; Implementation specific extension to flush output on ports. (cond-expand (guile ; Don't use define-syntax, that doesn't work on all guiles @@ -237,7 +250,7 @@ (define (init-sweet) ; Default guile stack size is FAR too small (debug-set! stack 50) - (values)) + (no-values)) ; Guile was the original development environment, so the algorithm ; practically acts as if it is in Guile. @@ -310,7 +323,7 @@ (define (setup-primitive-load) (cond (primitive-load-replaced - (values)) + (no-values)) (else (module-set! (resolve-module '(guile)) 'primitive-load (lambda (filename) @@ -463,7 +476,7 @@ (begin body ... ; A do-nothing. -(define (init-sweet) (values)) +(define (init-sweet) (no-values)) ; We use my-* procedures so that the ; port automatically keeps track of source position. @@ -594,9 +607,11 @@ (define keyword-syntax (make-parameter #f)) ; Returns a true value (not necessarily #t) + (: char-line-ending? (* -- boolean)) (define (char-line-ending? char) (memv char line-ending-chars)) ; Create own version, in case underlying implementation omits some. + (: my-char-whitespace? (char -- boolean)) (define (my-char-whitespace? c) (or (char-whitespace? c) (memv c whitespace-chars))) @@ -605,16 +620,18 @@ ; guile use annoying (EOF won't be correctly detected) due to a guile bug ; (in guile before version 2.0.8, peek-char incorrectly ; *consumes* EOF instead of just peeking). + (: consume-end-of-line (input-port - *)) (define (consume-end-of-line port) (let ((c (my-peek-char port))) (cond ((eqv? c carriage-return) - (my-read-char port) + (my-read-char port) (if (eqv? (my-peek-char port) linefeed) (my-read-char port))) ((eqv? c linefeed) (my-read-char port) + (: consume-to-eol (input-port - *)) ; FIXME (define (consume-to-eol port) ; Consume every non-eol character in the current line. ; End on EOF or end-of-line char. @@ -625,6 +642,7 @@ (my-read-char port) (consume-to-eol port) + (: consume-to-whitespace (input-port - (or eof null))) (define (consume-to-whitespace port) ; Consume to whitespace (let ((c (my-peek-char port))) @@ -648,6 +666,7 @@ (display \n))) data) + (: my-read-delimited-list (:reader-proc: char input-port - *)) (define (my-read-delimited-list my-read stop-char port) ; Read the inside of a list until its matching stop-char, returning list. ; stop-char needs to be closing paren, closing bracket, or closing brace. @@ -690,7 +709,9 @@ ; Read preservation, replacement, and mode setting ; - + (: default-scheme-read :reader-proc:) (define default-scheme-read read) + (: replace-read :reader-proc:) (define replace-read replace-read-with) (define (restore-traditional-read) (replace-read-with default-scheme-read)) @@ -708,8 +729,9 @@ (define (enable-sweet) (replace-read sweet-read)) - (define current-read-mode #f) + (define current-read-mode #f) ;; OBSOLETE? + (: set-read-mode deprecated) ; not yet, just as a
Re: [Readable-discuss] Fwd: Re: Supporting SRFI-110 in chicken (Joerg Wittenberger)
Am 18.11.2013 10:56, schrieb Jörg F. Wittenberger: Am 17.11.2013 22:17, schrieb David A. Wheeler: On Sun, 17 Nov 2013 15:13:09 -0500, John Cowan co...@mercury.ccil.org wrote: There is a gimmick we could use. We could create a reset port function that *REMOVES* the entry from the hashtable. Then, on next use, it'd recreate the entries. That would be a clean interface, but work efficiently in a portable way. That would mean that systems would need to reset ports if they create huge numbers of them. Sadly, I don't see how to deal with that cleanly without weak references. So far I did not understand why does this have to be port-specific in the first place. Maybe that would be the killer argument. I wonder: the code already creates fake port object wrappers. Wouldn't this be the natural place to stick such per-port settings into??!! Instead of all those global or parameters, just _copy_ one vector of default values into the fake port, like this: (define (make-read f) (lambda args (let ((port (if (null? args) (current-input-port) (car args (f (list port (vector-copy default-sweet-read-parameters)) Objections? Something why this would not get the job done? (Maybe that would work better, if there was a port-fake-port procedure and a dispatch in the make-read depending on whether an already-upgraded port or a plain port was passed in.) /Jörg -- DreamFactory - Open Source REST JSON Services for HTML5 Native Apps OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access Free app hosting. Or install the open source package on any LAMP server. Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native! http://pubads.g.doubleclick.net/gampad/clk?id=63469471iu=/4140/ostg.clktrk ___ Readable-discuss mailing list Readable-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/readable-discuss
[Readable-discuss] A road block: #:
In a first attempt to feed the source to some other Scheme I went ahead and sent it to the rscheme compiler. Doesn't work. It has the same problem as Guile: it will refuse to read certain #sharp syntax. **HALT** error: scan-token:439: #\# cannot be followed by #\: Is there a way in Guile to split source in multiple files? Would it acceptable to split the compatibility section out of the main code for sweet/kernel? Otherwise I don't see how to proceed for rscheme and foresee the same problem around the corner for some other Schemes too. Best Regards /Jörg -- DreamFactory - Open Source REST JSON Services for HTML5 Native Apps OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access Free app hosting. Or install the open source package on any LAMP server. Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native! http://pubads.g.doubleclick.net/gampad/clk?id=63469471iu=/4140/ostg.clktrk ___ Readable-discuss mailing list Readable-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/readable-discuss
[Readable-discuss] Getting the current development snapshot
On Mon, 18 Nov 2013 10:48:33 +0100, Jörg F. Wittenberger joerg.wittenber...@softeyes.net wrote: I'll deal with that. David, should I just keep patching or do you have a current snapshot of the accepted patches so far for me? It's always easiest to send me patches based on the git repo. Snag your own copy of the repo with: git clone git://git.code.sf.net/p/readable/code readable-code cd readable-code git checkout develop From then on, git pull will update from the remote repo. If you can't use git, you can snag just the kernel.scm file (develop version) from: https://sourceforge.net/p/readable/code/ci/develop/tree/src/kernel.scm?format=raw Note that the develop branch is what changes in development, while the master branch holds final distributed versions. --- David A. Wheeler -- DreamFactory - Open Source REST JSON Services for HTML5 Native Apps OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access Free app hosting. Or install the open source package on any LAMP server. Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native! http://pubads.g.doubleclick.net/gampad/clk?id=63469471iu=/4140/ostg.clktrk ___ Readable-discuss mailing list Readable-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/readable-discuss
Re: [Readable-discuss] Fwd: Re: Supporting SRFI-110 in chicken (Joerg Wittenberger)
On Mon, 18 Nov 2013 12:19:21 +0100, Jörg F. Wittenberger joerg.wittenber...@softeyes.net wrote: I wonder: the code already creates fake port object wrappers. Wouldn't this be the natural place to stick such per-port settings into??!! That's not a bad idea. I was hoping for the fake ports to be a temporary shim for certain cases, not something we end up using everywhere, but I think you're right that it's plausible. --- David A. Wheeler -- DreamFactory - Open Source REST JSON Services for HTML5 Native Apps OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access Free app hosting. Or install the open source package on any LAMP server. Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native! http://pubads.g.doubleclick.net/gampad/clk?id=63469471iu=/4140/ostg.clktrk ___ Readable-discuss mailing list Readable-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/readable-discuss
Re: [Readable-discuss] Fwd: Re: Supporting SRFI-110 in chicken (Joerg Wittenberger)
On Mon, 18 Nov 2013 10:56:41 +0100, Jörg F. Wittenberger joerg.wittenber...@softeyes.net wrote: So far I did not understand why does this have to be port-specific in the first place. Maybe that would be the killer argument. It's by analogy to other read settings, such as fold-case, so it's spec'ed that way. Maybe not: at least in my case, I'd be *happy* to have a way to compile-time the feature away eventually, since I know these settings will not change. The current implementation is close to that. Currently settings like these are global to the implementation. In practice, most people don't futz with these settings (except at program begin), so it's worked fine. --- David A. Wheeler -- DreamFactory - Open Source REST JSON Services for HTML5 Native Apps OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access Free app hosting. Or install the open source package on any LAMP server. Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native! http://pubads.g.doubleclick.net/gampad/clk?id=63469471iu=/4140/ostg.clktrk ___ Readable-discuss mailing list Readable-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/readable-discuss
Re: [Readable-discuss] A road block: #:
Am 18.11.2013 15:25, schrieb David A. Wheeler: On Mon, 18 Nov 2013 13:23:32 +0100, Jörg F. Wittenberger joerg.wittenber...@softeyes.net wrote: In a first attempt to feed the source to some other Scheme I went ahead and sent it to the rscheme compiler. Doesn't work. It has the same problem as Guile: it will refuse to read certain #sharp syntax. **HALT** error: scan-token:439: #\# cannot be followed by #\: Is there a way in Guile to split source in multiple files? Would it acceptable to split the compatibility section out of the main code for sweet/kernel? Otherwise I don't see how to proceed for rscheme and foresee the same problem around the corner for some other Schemes too. I presume the problem is in this guile-specific code: (use-modules ((srfi srfi-69) #:select We can't replace #:select with (symbol-keyword 'select) unfortunately; guile won't recognize it. I suspect what we should do is right there temporarily have guile use prefix keyword notation (:select), using something like (read-set! keywords 'prefix), and then restore whatever was there before. Then other Schemes can read it. If that is possible, great! No comments so far on the possibility to put these things into platform-specific files? /Jörg -- Shape the Mobile Experience: Free Subscription Software experts and developers: Be at the forefront of tech innovation. Intel(R) Software Adrenaline delivers strategic insight and game-changing conversations that shape the rapidly evolving mobile landscape. Sign up now. http://pubads.g.doubleclick.net/gampad/clk?id=63431311iu=/4140/ostg.clktrk ___ Readable-discuss mailing list Readable-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/readable-discuss
Re: [Readable-discuss] Fwd: Re: Supporting SRFI-110 in chicken (Joerg Wittenberger)
Am 18.11.2013 15:28, schrieb David A. Wheeler: On Mon, 18 Nov 2013 12:19:21 +0100, Jörg F. Wittenberger joerg.wittenber...@softeyes.net wrote: I wonder: the code already creates fake port object wrappers. Wouldn't this be the natural place to stick such per-port settings into??!! That's not a bad idea. I was hoping for the fake ports to be a temporary shim for certain cases, I'm afraid I've seen so many cases, which could be solved by custom port refinements, that the only thing which is badly missing is a standard way to define custom ports. :-/ Just I'm short on any proposal to do just that. It's about as simple as coming up with the srfi for object oriented extensions to Scheme. A can of worms. not something we end up using everywhere, but I think you're right that it's plausible. So if nobody objects. ... ?? /Jörg -- Shape the Mobile Experience: Free Subscription Software experts and developers: Be at the forefront of tech innovation. Intel(R) Software Adrenaline delivers strategic insight and game-changing conversations that shape the rapidly evolving mobile landscape. Sign up now. http://pubads.g.doubleclick.net/gampad/clk?id=63431311iu=/4140/ostg.clktrk ___ Readable-discuss mailing list Readable-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/readable-discuss
Re: [Readable-discuss] noop patch - add type information
On Mon, 18 Nov 2013 12:09:43 +0100, Jörg F. Wittenberger joerg.wittenber...@softeyes.net wrote: Attached a slightly better version of the add types patch. This one replaces (values) with a (no-values) syntax from the compatibility layer and has those procedures, which used to return no values or undefined values type-annotated as returning undefined. Thanks! I had to tweak them, but we now use (no-values). Note: Yesterday I added annotations for some of the procedures you didn't annotate. --- David A. Wheeler -- Shape the Mobile Experience: Free Subscription Software experts and developers: Be at the forefront of tech innovation. Intel(R) Software Adrenaline delivers strategic insight and game-changing conversations that shape the rapidly evolving mobile landscape. Sign up now. http://pubads.g.doubleclick.net/gampad/clk?id=63431311iu=/4140/ostg.clktrk ___ Readable-discuss mailing list Readable-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/readable-discuss
Re: [Readable-discuss] A road block: #:
Am 18.11.2013 15:25, schrieb David A. Wheeler: On Mon, 18 Nov 2013 13:23:32 +0100, Jörg F. Wittenberger joerg.wittenber...@softeyes.net wrote: In a first attempt to feed the source to some other Scheme I went ahead and sent it to the rscheme compiler. Doesn't work. It has the same problem as Guile: it will refuse to read certain #sharp syntax. Okay, the source code no longer has #:. The result is extremely magical guile code, to work around some wonkiness in old versions of guile, but the magic is explained in comments. --- David A. Wheeler -- Shape the Mobile Experience: Free Subscription Software experts and developers: Be at the forefront of tech innovation. Intel(R) Software Adrenaline delivers strategic insight and game-changing conversations that shape the rapidly evolving mobile landscape. Sign up now. http://pubads.g.doubleclick.net/gampad/clk?id=63431311iu=/4140/ostg.clktrk ___ Readable-discuss mailing list Readable-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/readable-discuss
Re: [Readable-discuss] noop patch - add type information
Jörg F. Wittenberger scripsit: IMHO there should be no undefined *value* as such. It should be just undefined what's being returned. If - for some reason - some fake value need to be there to satisfy some other condition, so be it. But Scheme would IMHO be better off along the default Racket way. See http://trac.sacrideo.us/wg/wiki/OneArmedIf for details on how different Schemes do it. There is a fairly strong consensus to return an undefined-value value, but no Scheme standard prescribes such an object. -- Evolutionary psychology is the theory John Cowan that men are nothing but horn-dogs, http://www.ccil.org/~cowan and that women only want them for their money. co...@ccil.org --Susan McCarthy (adapted) -- Shape the Mobile Experience: Free Subscription Software experts and developers: Be at the forefront of tech innovation. Intel(R) Software Adrenaline delivers strategic insight and game-changing conversations that shape the rapidly evolving mobile landscape. Sign up now. http://pubads.g.doubleclick.net/gampad/clk?id=63431311iu=/4140/ostg.clktrk ___ Readable-discuss mailing list Readable-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/readable-discuss