[Chicken-hackers] Suggestion for the ports unit: port-pipe
Dear Chickenados, I frequently find myself wanting/implementing a procedure which I shall call `port-pipe'. As the name suggests, its purpose is piping data from one port to another. As I find it very handy and general-purposey, I propose it for inclusion in the ports unit. Without further ado, here is the procedure: (define (port-pipe #!key (from (current-input-port)) (to (current-output-port)) (read read-char) (write write-char)) (with-output-to-port to (lambda () (with-input-from-port from (lambda () (port-for-each write read)) Usage examples: (call-with-input-request "http://call-cc.org/"; #f (cut port-pipe)) (call-with-input-file "foo" (lambda (file) (port-pipe from: file to: (current-error-port Okay, some further ado: AFAIK, read-char/write-char are not the most performant options compared to say read-line/write-line, but it's the most robust default since it pipes contents unaltered as opposed to write-line which always appends a newline even if there was none in the input previously read by read-line (this unorthogonality is maybe not quite optimal but changing read-line's behavior would probably break a lot of code so I refrain from suggesting it). I am neither married to the signature nor the default arguments nor the implementation, so comments are welcome. Also let me know if this procedure might be completely silly and useless. I'd love to know why though :-) I have a few tests lying around for this, too. Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] Suggestion for the ports unit: port-pipe
Felix writes: > I'd call it `port-copy'. I thought of that, too, but it sounds like it would copy the port objects rather than stream their contents. Maybe `port-stream'? I'm not sure :-) What do you think about its usefulness? I might as well just make an egg for it if you think it's too specific to be included in the core distribution. Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] Suggestion for the ports unit: port-pipe
Hi, Thomas Chust writes: > If CHICKEN got a procedure for the same purpose, I think it would > definitely make sense to make it compatible with this calling > convention as well. ah, good catch! Being compatible with other Schemes would be a plus. However positioned arguments are a bit cumbersome for this kind of procedure as all kinds of combinations are conceivably useful. We could have `copy-port' built on top of the more flexible keyword version though. Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-hackers
[Chicken-hackers] importing modules of not yet loaded extensions
Fellow Chickeneers, when investigating the problem described in ticket #450, Christian and I had a discussion about whether it makes sense to be able to import modules for which the extension defining them has not yet been loaded. In the situation described in the ticket this was the case with the posix extension. This might suggest that it's just some core unit oddity but it does indeed work with modules defined in eggs, too. Just try to run csi -n and (import chicken-doc) or any other egg you happen to have installed and you'll notice that all necessary .import.so files will be loaded but, of course, no binding will be imported at all. Thus I figured it may make sense to make importing modules which aren't actually loaded signal an error or at least output a warning to catch problems like this early on. It may be that I am misunderstanding something about import's purpose. However, we could not really settle for a satisfying explanation or solution. Any comments? Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] importing modules of not yet loaded extensions
Felix writes: > Being able to import a module without requiring the loading of the > libary is necessary to allow cross-compilation. Chicken separates this > and I consider it a feature. Right, Christian pointed this out, too. I wonder though: Are modules which use `require-extension' cross-compilable then at all? Or does the compiler somehow prevent the actual loading from taking place, effectively replacing them by just an `import'? If that is indeed the case, why not make `import' behave like `require-extension' in the first place? Or am I missing something obvious? > Remember the mantra: > > If in doubt, use `require-extension'. Amen! Good night for now :-) Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] functors
Hi Felix, Felix writes: > Anyway, that's it. functorific! One question: right now it is necessary to define an intermediary module and then another one to actually instantiate the functor like. in this example from the documentation: (module nums (multiply) (import scheme) (define (multiply x y) (* x y))) (module number-squarer = (squaring-functor nums)) Maybe I didn't understand it all correctly but is there syntax for folding that into one definition? E.g. something like this: (module number-squarer ((instantiates: squaring-functor)) (import scheme) (define (multiply x y) (* x y))) My guess is that the intermediary module would rarely be used on its own so most of the time it would just clutter the module namespace. But I may very well be mistaken. Also, `instantiates' is just what first came to mind ;-) Thanks for that cool feature, looking forward to playing with it! Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] Request to edit manual Foreign type specifiers
Jim Ursetto writes: > 1) A dedicated tag: , ; I suggest adding a dash of dashes, e.g. > Thoughts, anyone? I don't really get the difference between and , can you elaborate on that? > Also, let me know whether lighting up the import specifiers even makes > sense in the first place. I think so, yes, as I found myself searching for them in chicken-doc a few times! Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] CR: expt should signal error on domain error
Felix writes: > Is this intuition, or are you simply being used to it? I learned in > School that division by zero is invalid. To be fair, Peter was suggesting that changing expt to behave differently from fexpt might be unintuitive, not division by zero behaving different for different numeric representations. That's a differently differing difference. > This deeply disappoints me. You all are a bunch of robots. Who would have thought that floating point numbers can stir emotions like that! On second thought ... Indifferently, Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
[Chicken-hackers] [PATCH] Add non-destructive version of alist-update!
Hi all, I'd like to continue with Christian's initiative. Find attached a simple patch that adds a non-destructive version of alist-update! named (obviously) alist-update to the data-structures unit. It also updates the manual accordingly and adds a few test cases for both alist-update! and alist-update. Since the patch is so trivial I won't discuss it in detail, just take a look and you'll get the idea :-) Regards Moritz >From 58fde20c0eefd7527886bb5342ac1489b805f4bc Mon Sep 17 00:00:00 2001 From: Moritz Heidkamp Date: Tue, 6 Sep 2011 15:03:06 +0200 Subject: [PATCH] add non-destructive version of alist-update! named alist-update and add some tests for both of them --- data-structures.import.scm |1 + data-structures.scm |3 +++ manual/Unit data-structures |7 --- tests/data-structures-tests.scm | 18 ++ tests/runtests.sh |3 +++ 5 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 tests/data-structures-tests.scm diff --git a/data-structures.import.scm b/data-structures.import.scm index 245c7c4..2fd71bf 100644 --- a/data-structures.import.scm +++ b/data-structures.import.scm @@ -29,6 +29,7 @@ '(->string alist-ref alist-update! + alist-update always?; DEPRECATED any? atom? diff --git a/data-structures.scm b/data-structures.scm index 7da3698..7cb8e98 100644 --- a/data-structures.scm +++ b/data-structures.scm @@ -231,6 +231,9 @@ EOF lst) (cons (cons x y) lst) ) ) ) +(define (alist-update k v lst #!optional (cmp eqv?)) + (alist-update! k v (map (lambda (elt) (cons (car elt) (cdr elt))) lst) cmp)) + (define (alist-ref x lst #!optional (cmp eqv?) (default #f)) (let* ([aq (cond [(eq? eq? cmp) assq] [(eq? eqv? cmp) assv] diff --git a/manual/Unit data-structures b/manual/Unit data-structures index 6f3e8c1..5412ea4 100644 --- a/manual/Unit data-structures +++ b/manual/Unit data-structures @@ -19,15 +19,16 @@ Looks up {{KEY}} in {{ALIST}} using {{TEST}} as the comparison function (or {{eq no test was given) and returns the cdr of the found pair, or {{DEFAULT}} (which defaults to {{#f}}). - alist-update! + alist-update +(alist-update KEY VALUE ALIST [TEST]) (alist-update! KEY VALUE ALIST [TEST]) If the list {{ALIST}} contains a pair of the form {{(KEY . X)}}, then this procedure replaces {{X}} with {{VALUE}} and returns {{ALIST}}. If {{ALIST}} contains no such item, then -{{alist-update!}} returns {{((KEY . VALUE) . ALIST)}}. The optional argument +{{alist-update}} returns {{((KEY . VALUE) . ALIST)}}. The optional argument {{TEST}} specifies the comparison procedure to search a matching pair in {{ALIST}} -and defaults to {{eqv?}}. +and defaults to {{eqv?}}. {{alist-update!}} is the destructive version of {{alist-update}}. atom? diff --git a/tests/data-structures-tests.scm b/tests/data-structures-tests.scm new file mode 100644 index 000..df4b559 --- /dev/null +++ b/tests/data-structures-tests.scm @@ -0,0 +1,18 @@ + data-structures-tests.scm + + +(use data-structures) + +(let ((alist '((foo . 123) ("bar" . "baz" + (alist-update! 'foo 999 alist) + (assert (= (alist-ref 'foo alist) 999)) + (alist-update! 'qux 'nope alist) + (assert (not (alist-ref 'qux alist))) + (assert (eq? 'yep (alist-ref 'qux (alist-update! 'qux 'yep alist + (assert (eq? 'ok (alist-ref "bar" (alist-update! "bar" 'ok alist equal?) equal? + +(let ((alist '((foo . 123) ("bar" . "baz" + (alist-update 'foo 999 alist) + (assert (= (alist-ref 'foo alist) 123)) + (assert (eq? 'yep (alist-ref 'qux (alist-update 'qux 'yep alist + (assert (eq? 'ok (alist-ref "bar" (alist-update "bar" 'ok alist equal?) equal? \ No newline at end of file diff --git a/tests/runtests.sh b/tests/runtests.sh index 4a24457..f0c19ce 100644 --- a/tests/runtests.sh +++ b/tests/runtests.sh @@ -294,6 +294,9 @@ echo " srfi-18 tests ..." $interpret -s simple-thread-test.scm $interpret -s mutex-test.scm +echo " data-structures tests ..." +$interpret -s data-structures-tests.scm + echo " path tests ..." $interpret -bnq path-tests.scm -- 1.7.6.1 ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] Add non-destructive version of alist-update!
Hi Felix, Felix writes: > Thanks, Moritz. Here a few suggestions: > > - alist-update copies more of the argument list than necessary, it > only has to copy up to the first matching entry > - an entry for types.db is missing thanks for the feedback, attached is an updated version of the patch. I hope I got the types.db entry right! By the way: I noticed that when an unknown comparison procedure is passed alist-update! it will also accept non-alists, e.g.: #;1> (alist-update! 123 123 '(x y z) =) ((123 . 123) x y z) Whereas for example the default (eqv?) gives: #;2> (alist-update! 123 123 '(x y z)) Error: (assv) bad argument type: x Not sure if this is really a problem. Moritz >From fa0a758cf2bac89a5507c6aaf548527974e2ef1d Mon Sep 17 00:00:00 2001 From: Moritz Heidkamp Date: Tue, 13 Sep 2011 15:17:10 +0200 Subject: [PATCH] add alist-update, a non-destructive version of alist-update! alist-update only copies as much of the alist as needed (i.e. up until the matching pair) add documentation and a types.db entry for alist-update add tests for both alist-update and alist-update! --- data-structures.import.scm |1 + data-structures.scm | 13 + manual/Unit data-structures |7 --- tests/data-structures-tests.scm | 18 ++ tests/runtests.sh |3 +++ types.db|1 + 6 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 tests/data-structures-tests.scm diff --git a/data-structures.import.scm b/data-structures.import.scm index 245c7c4..2fd71bf 100644 --- a/data-structures.import.scm +++ b/data-structures.import.scm @@ -29,6 +29,7 @@ '(->string alist-ref alist-update! + alist-update always?; DEPRECATED any? atom? diff --git a/data-structures.scm b/data-structures.scm index 7da3698..8d47f7f 100644 --- a/data-structures.scm +++ b/data-structures.scm @@ -231,6 +231,19 @@ EOF lst) (cons (cons x y) lst) ) ) ) +(define (alist-update k v lst #!optional (cmp eqv?)) + (let loop ((lst lst)) +(if (null? lst) +(list (cons k v)) +(let ((a (##sys#slot lst 0))) + (cond ((not (pair? a)) + (error 'alist-update "bad argument type" a)) +((cmp (##sys#slot a 0) k) + (cons (cons k v) (##sys#slot lst 1))) +(else + (cons (cons (##sys#slot a 0) (##sys#slot a 1)) + (loop (##sys#slot lst 1) + (define (alist-ref x lst #!optional (cmp eqv?) (default #f)) (let* ([aq (cond [(eq? eq? cmp) assq] [(eq? eqv? cmp) assv] diff --git a/manual/Unit data-structures b/manual/Unit data-structures index 6f3e8c1..5412ea4 100644 --- a/manual/Unit data-structures +++ b/manual/Unit data-structures @@ -19,15 +19,16 @@ Looks up {{KEY}} in {{ALIST}} using {{TEST}} as the comparison function (or {{eq no test was given) and returns the cdr of the found pair, or {{DEFAULT}} (which defaults to {{#f}}). - alist-update! + alist-update +(alist-update KEY VALUE ALIST [TEST]) (alist-update! KEY VALUE ALIST [TEST]) If the list {{ALIST}} contains a pair of the form {{(KEY . X)}}, then this procedure replaces {{X}} with {{VALUE}} and returns {{ALIST}}. If {{ALIST}} contains no such item, then -{{alist-update!}} returns {{((KEY . VALUE) . ALIST)}}. The optional argument +{{alist-update}} returns {{((KEY . VALUE) . ALIST)}}. The optional argument {{TEST}} specifies the comparison procedure to search a matching pair in {{ALIST}} -and defaults to {{eqv?}}. +and defaults to {{eqv?}}. {{alist-update!}} is the destructive version of {{alist-update}}. atom? diff --git a/tests/data-structures-tests.scm b/tests/data-structures-tests.scm new file mode 100644 index 000..df4b559 --- /dev/null +++ b/tests/data-structures-tests.scm @@ -0,0 +1,18 @@ + data-structures-tests.scm + + +(use data-structures) + +(let ((alist '((foo . 123) ("bar" . "baz" + (alist-update! 'foo 999 alist) + (assert (= (alist-ref 'foo alist) 999)) + (alist-update! 'qux 'nope alist) + (assert (not (alist-ref 'qux alist))) + (assert (eq? 'yep (alist-ref 'qux (alist-update! 'qux 'yep alist + (assert (eq? 'ok (alist-ref "bar" (alist-update! "bar" 'ok alist equal?) equal? + +(let ((alist '((foo . 123) ("bar" . "baz" + (alist-update 'foo 999 alist) + (assert (= (alist-ref 'foo alist) 123)) + (assert (eq? 'yep (alist-ref 'qux (alist-update 'qux 'yep alist + (assert (eq? 'ok (alist-ref "bar" (alist-update "bar" 'ok alist equal?) equal? \ No newline at end of file diff --git a/tests/runtests.sh b/tests/runtests.sh index 4a24457..f0c19ce 100644 --- a/tests/runtests.sh +++ b/tests/runtests.sh @@
Re: [Chicken-hackers] [PATCH] Add non-destructive version of alist-update!
Hi Felix, Felix writes: > I applied it and signed off [34ae5a3]. I took the freedom to add an > entry for tests/data-structures-tests.scm in distribution/manifest and > fixed a missing argument in the entry in types.db. thanks for catching that! I didn't actually know about distribution/manifest so the new process has already taught me two things about the core system :-) Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] Remove old variant of find-files
Christian Kellermann writes: > this is a simple patch to remove the deprecated variant of find-files. > As it is now the old variant is always choosen when calling find-files > with just 1 argument. Looks good to me! I don't really get that "we want `cons' inlined" comment in the original version. Why doesn't direct passing of cons lead to inlining? > There is one discrepancy left as we do follow symlinks by default > and the docs say the opposite. Which way is the better behaviour? > I will change either the default or the docs then. I'm not entirely sure what would be a sensible default myself. FWIW the GNU find program doesn't follow symlinks by default. Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [Chicken-users] happy christmas!
Felix writes: > I wish everybody a very happy christmas and a joyful new year. Thanks and the same to you and all other Chickeneers! It's been a great year of clucking :-) Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
[Chicken-hackers] Properly handling process ports
Fellow Chickeneers, I'd like to direct your attention to this ticket I just created: https://bugs.call-cc.org/ticket/766 - maybe somebody with greater POSIX-fu than me can point out whether I am doing something completely wrong. Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
[Chicken-hackers] [PATCH] Add `module-environments' feature
Hello Chickenauts, the attached patch merely adds a `module-environments' feature which indicates the availability of the new `module-environment' function. This feature would be very nice to have for the new environments egg implementation in order to be able to cond-expand to the old implementation for earlier Chicken versions. I somebody agrees! Moritz >From 4f326e219248d4de807381af9df9edad6daedf4e Mon Sep 17 00:00:00 2001 From: Moritz Heidkamp Date: Sun, 5 Feb 2012 20:37:02 +0100 Subject: [PATCH] register `module-environments' feature to indicate availability of the `module-environment' function --- modules.scm |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/modules.scm b/modules.scm index f248890..8b048a3 100644 --- a/modules.scm +++ b/modules.scm @@ -882,6 +882,8 @@ (##sys#register-module-alias 'r5rs 'scheme) +(register-feature! 'module-environments) + (define (module-environment mname #!optional (ename mname)) (let* ((mod (##sys#find-module/import-library mname 'module-environment)) (saved (module-saved-environments mod))) -- 1.7.9 ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] Add `module-environments' feature
Moritz Heidkamp writes: > [...] I somebody agrees! ^ hope ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] Add `module-environments' feature
Felix writes: > Signed off and pushed. I fear we will end up with many arbitrary feature > identifiers at some stage, though. Perhaps we should find a method to > distinguish "system" features like this and avoid collisions with user- > defined features? Any ideas? Perhaps a `chicken-', 'core-' or maybe even a `sys##' prefix would do the trick? I wouldn't introduce a new namespace just for that I think. Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
[Chicken-hackers] Thrush operator
Hello Chickeneers, find attached a suggested addition to miscmacros: the thrush operator family. Apparently it stems from Raymond Smullyan's book on combinatorial logic "To Mock a Mockingbird", which I haven't read (yet). I've first learned about it through Clojure and have found it quite nice for increasing the readability of chained calls. See Debasish Ghosh's post [1] about it for some background. As a practical example, consider this code: (write (fold + 0 (map (lambda (i) (* 2 i)) (iota 10 Using the thrush operator it can be written like this: (->> (iota 10) (map (lambda (i) (* 2 i))) (fold + 0) (write)) which basically expands to the expression above, i.e. it inserts each expression as the last argument of the following expression. I find it much easier to read though since the order of evaluation is the order of appearance in the code. I like to think of it like `let*' as opposed to nested `lambda': ((lambda (x) ((lambda (y) ((lambda (z) (+ x y z)) 3)) 2)) 1) versus: (let* ((x 1) (y 2) (z 3)) (+ x y z)) Much easier to track what's going on there as stuff that belongs together is visually close to each other. There's also `->' which inserts each expression as the first argument of the following one. The difference: (->> 10 (- 3)) ; => -7 (-> 10 (- 3)) ; => 7 For kicks and fun I also added starred versions (`->*' and `->>*') which are multi-value aware. Not sure how useful that is and I didn't want to add it to the default macros to avoid the overhead. But it's good to have them just for completeness sake! I guess that's about it. I'm not sure if adding it to miscmacros is a great idea, might as well just create a `thrush' egg. OTOH we have the similar `doto' macro in there already. Comments? Moritz [1] http://debasishg.blogspot.com/2010/04/thrush-in-clojure.html Index: miscmacros.scm === --- miscmacros.scm (revision 25904) +++ miscmacros.scm (working copy) @@ -9,13 +9,14 @@ define-optionals define-parameter define-enum ignore-values ignore-errors ecase - define-syntax-rule) + define-syntax-rule + -> ->* ->> ->>*) (import scheme) ;; No effect -- caller must import these manually. (import (only chicken when unless handle-exceptions let-optionals make-parameter -add1 sub1)) +add1 sub1 define-for-syntax)) ;;; Modify locations, T-like: @@ -303,4 +304,55 @@ clauses ... (else (error "no valid case" val +(define-for-syntax (expand-thrush x weave) + (let loop ((y (cdr x)) (form (car x))) +(if (null? y) +form +(let ((z (car y))) + (loop (cdr y) +(weave z form)) + +(define-syntax -> + (ir-macro-transformer + (lambda (x i c) + (expand-thrush + (cdr x) + (lambda (z form) +(cons (car z) + (cons form (cdr z + +(define-syntax ->* + (ir-macro-transformer + (lambda (x i c) + (expand-thrush + (cdr x) + (lambda (z form) +`(receive args ,form + (apply +,(car z) +(append args (list . ,(cdr z)) + +(define-syntax ->> + (ir-macro-transformer + (lambda (x i c) + (expand-thrush + (cdr x) + (lambda (z form) +(append z (list form))) + +(define-syntax ->>* + (ir-macro-transformer + (lambda (x i c) + (expand-thrush + (cdr x) + (lambda (z form) +`(receive args ,form + (apply +,(car z) +(append (list . ,(cdr z)) args + ) + + + + Index: tests/run.scm === --- tests/run.scm (revision 0) +++ tests/run.scm (working copy) @@ -0,0 +1,22 @@ +(use test srfi-1 miscmacros) + +(test 1 (-> 99 (/ 11) (/ 9))) + +(test '(1 2 3 4) + (->* (values 1 2) + (list 3) + (append '(4 + +(test 7 (-> 10 (- 3))) +(test -7 (->> 10 (- 3))) + +(test 9 (->> 1 (+ 2) (* 3))) + +(test 9 (->> '(1 2 3) + (map add1) + (fold + 0))) + +(test '((foo . 100) (bar . 200)) + (->>* (values '(foo bar) '(100 200)) +(map cons))) + ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] Thrush operator
Hi Jörg, Jörg F. Wittenberger writes: > I rather loved to think instead of "inserting the (*single*) > value of the expression into the next expression" of something > along the lines of physical wires: > connect (pass) all the result(s) of the first expression into the next > (which would then need to accept as many values as the stage > before returns. if I understand you correctly, this is exactly what the starred versions, `->*' and `->>*', do. Or did I get you wrong? Peter had another idea worth considering: using placeholders like `cut' and `cute' do: (-> "world" (list "hello" <>) (string-intersperse <> ",") (print <> ".")) As this silly example demonstrates this could be used to "wire" values into arbitrary argument positions. It's a bit more flexible and it may be clearer what's going on but also adds some line noise. I have to think about that! Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] Thrush operator
Moritz Heidkamp writes: > find attached a suggested addition to miscmacros Attached a syntax-rules based implementation which is much easier to grok. I am leaning towards putting those into a separate egg now though. Index: miscmacros.scm === --- miscmacros.scm (revision 25904) +++ miscmacros.scm (working copy) @@ -9,7 +9,8 @@ define-optionals define-parameter define-enum ignore-values ignore-errors ecase - define-syntax-rule) + define-syntax-rule + -> ->* ->> ->>*) (import scheme) ;; No effect -- caller must import these manually. @@ -303,4 +304,32 @@ clauses ... (else (error "no valid case" val +(define-syntax -> + (syntax-rules () +((_ x) x) +((_ x (y z ...) rest ...) + (-> (y x z ...) rest ... + +(define-syntax ->> + (syntax-rules () +((_ x) x) +((_ x (y ...) rest ...) + (->> (y ... x) rest ... + +(define-syntax ->* + (syntax-rules () +((_ x) x) +((_ x (y z ...) rest ...) + (->* (receive args x +(apply y (append args (list z ... + rest ... + +(define-syntax ->>* + (syntax-rules () +((_ x) x) +((_ x (y z ...) rest ...) + (->>* (receive args x + (apply y (append (list z ...) args))) + rest ... + ) Index: tests/run.scm === --- tests/run.scm (revision 0) +++ tests/run.scm (working copy) @@ -0,0 +1,22 @@ +(use test srfi-1 miscmacros) + +(test 1 (-> 99 (/ 11) (/ 9))) + +(test '(1 2 3 4) + (->* (values 1 2) + (list 3) + (append '(4 + +(test 7 (-> 10 (- 3))) +(test -7 (->> 10 (- 3))) + +(test 9 (->> 1 (+ 2) (* 3))) + +(test 9 (->> '(1 2 3) + (map add1) + (fold + 0))) + +(test '((foo . 100) (bar . 200)) + (->>* (values '(foo bar) '(100 200)) +(map cons))) + ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] Thrush operator
Felix writes: > I think that's a good idea. You could also add the "doto" operator > from the miscmacros there, since I don't think it fits well into > the set of macros provided by miscmacros. Alright, it's done, meet http://wiki.call-cc.org/eggref/4/clojurian :-) I took the liberty to rewrite `doto' in terms of `syntax-rules'. Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] Bugfix for #791 and unpack flonums correctly for integer?
Christian Kellermann writes: > Since I also agree and I *wrote* *this* *patch* we are deadlocked. > Attention! Robots need your help! I had a look at it but am too clueless about that numbers business to give a confident review, alas. Any other takers? ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] Capture length in case-lambda to make it hygienic
Hi Christian, Christian Kellermann writes: > the attached patch fixes #805, by capturing the core length procedure > correctly. Thanks go to Moritz for finding and reporting this issue. I found yet another hygiene issue in `case-lambda' in the meantime and a similar one in `ensure'. The attached patches address these also add some regression tests. Thanks again for your help! Moritz >From a441b07473a93f5216c31ae23dd993ff61958f15 Mon Sep 17 00:00:00 2001 From: Moritz Heidkamp Date: Sun, 25 Mar 2012 14:24:07 +0200 Subject: [PATCH 1/3] Fix hygiene issues in `case-lambda' This adresses bug #805 --- chicken-syntax.scm | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/chicken-syntax.scm b/chicken-syntax.scm index 08bede2..b634d1f 100644 --- a/chicken-syntax.scm +++ b/chicken-syntax.scm @@ -764,7 +764,8 @@ `((>= . ,(##sys#primitive-alias '>=)) (car . ,(##sys#primitive-alias 'car)) (cdr . ,(##sys#primitive-alias 'cdr)) - (eq? . ,(##sys#primitive-alias 'eq?))) + (eq? . ,(##sys#primitive-alias 'eq?)) + (length . ,(##sys#primitive-alias 'length))) (##sys#er-transformer (lambda (form r c) (##sys#check-syntax 'case-lambda form '(_ . _)) @@ -785,11 +786,12 @@ (%>= (r '>=)) (%eq? (r 'eq?)) (%car (r 'car)) - (%cdr (r 'cdr))) + (%cdr (r 'cdr)) + (%length (r 'length))) `(##core#lambda ,(append minvars rvar) (##core#let - ((,lvar (length ,rvar))) +((,lvar (,%length ,rvar))) ,(fold-right (lambda (c body) (##sys#decompose-lambda-list @@ -820,7 +822,7 @@ bindings `(##core#let ,(map list vars1 minvars) ,bindings) ) ) ) ,body) ) ) ) - '(##core#check (##sys#error (##core#immutable '"no matching clause in call to 'case-lambda' form"))) + '(##core#check (##sys#error (##core#immutable (##core#quote "no matching clause in call to 'case-lambda' form" (cdr form -- 1.7.9.4 >From 7ef5a447cfdde5214b95a8648501e1483c33a805 Mon Sep 17 00:00:00 2001 From: Moritz Heidkamp Date: Sun, 25 Mar 2012 14:24:19 +0200 Subject: [PATCH 2/3] Fix hygiene issue in `ensure' --- chicken-syntax.scm |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chicken-syntax.scm b/chicken-syntax.scm index b634d1f..2ea7072 100644 --- a/chicken-syntax.scm +++ b/chicken-syntax.scm @@ -208,8 +208,8 @@ #:type-error ,@(if (pair? args) args - `((##core#immutable '"argument has incorrect type") - ,tmp ',pred) ) ) ) ) ) ) ) ) + `((##core#immutable (##core#quote "argument has incorrect type")) + ,tmp (##core#quote ,pred)) ) ) ) ) ) ) ) ) (##sys#extend-macro-environment 'fluid-let '() -- 1.7.9.4 >From 75a09261c6ae737f6f42dd44bc737fcaa060186c Mon Sep 17 00:00:00 2001 From: Moritz Heidkamp Date: Sun, 25 Mar 2012 14:24:35 +0200 Subject: [PATCH 3/3] Add regression tests for fixes introduced in a441b074 and 7ef5a447 --- tests/syntax-tests.scm |7 +++ 1 file changed, 7 insertions(+) diff --git a/tests/syntax-tests.scm b/tests/syntax-tests.scm index 21f57e5..bb2e2d2 100644 --- a/tests/syntax-tests.scm +++ b/tests/syntax-tests.scm @@ -967,3 +967,10 @@ (use (prefix srfi-1 list-)) take + + +;; #805: case-lambda is unhygienic (as well as ensure, see c1160ca7 and 7fe07e9c) +(module foo () + (import (prefix chicken c/) (prefix scheme s/)) + (c/case-lambda ((a) a)) + (c/ensure s/even? 2)) -- 1.7.9.4 ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] Capture length in case-lambda to make it hygienic
Christian Kellermann writes: > I have amended your test's commit message and comment to reflect > the correct commit hashes (I hope). Other than that these are fine > and I've pushed them. Thanks a bunch! I have another small patch which renames the regression test module to be slightly more descriptive. I already have the need for yet another hygiene regression test so I guess it makes sense to properly name those modules :-) Moritz >From 12aa01799de4baa6dae5ef223a9783b1f85e7889 Mon Sep 17 00:00:00 2001 From: Moritz Heidkamp Date: Sun, 25 Mar 2012 16:36:27 +0200 Subject: [PATCH] give the #805 regression test module a more descriptive name --- tests/syntax-tests.scm |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/syntax-tests.scm b/tests/syntax-tests.scm index 82a3850..c1a2fa8 100644 --- a/tests/syntax-tests.scm +++ b/tests/syntax-tests.scm @@ -970,7 +970,7 @@ take ;; #805: case-lambda is unhygienic (as well as ensure, see 4706afb4 and bc5cc698) -(module foo () +(module case-lambda-and-ensure-hygiene () (import (prefix chicken c/) (prefix scheme s/)) (c/case-lambda ((a) a)) (c/ensure s/even? 2)) -- 1.7.9.4 ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
[Chicken-hackers] [PATCH] Correct the types.db entry for `eval'
Hello Chicken friends, the attached patch corrects the types.db entry for the `eval' function to allow multiple return values. I also added some tests to library-tests.scm for a lack of more suitable better place. Moritz >From 3ad6146e9b9e87c43f37ae511f025be2af117f0d Mon Sep 17 00:00:00 2001 From: Moritz Heidkamp Date: Sat, 14 Apr 2012 20:37:06 +0200 Subject: [PATCH] Correct the types.db entry for `eval' to allow multiple return values. --- tests/library-tests.scm |6 ++ types.db|2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/library-tests.scm b/tests/library-tests.scm index f133f3f..1268bd4 100644 --- a/tests/library-tests.scm +++ b/tests/library-tests.scm @@ -278,3 +278,9 @@ (assert-fail (make-blob -1)) (assert-fail (make-vector -1)) + +;;; eval return values + +(assert (= 1 (eval 1))) +(assert (eq? '() (receive (eval '(values) +(assert (equal? '(1 2 3) (receive (eval '(values 1 2 3) diff --git a/types.db b/types.db index be90225..7aed56f 100644 --- a/types.db +++ b/types.db @@ -659,7 +659,7 @@ (let ((#(tmp2) #(2))) (#(tmp2) (#(tmp1))) -(eval (procedure eval (* #!optional (struct environment)) *)) +(eval (procedure eval (* #!optional (struct environment)) . *)) (char-ready? (#(procedure #:enforce) char-ready? (#!optional input-port) boolean)) (imag-part (#(procedure #:clean #:enforce) imag-part (number) number) -- 1.7.9.4 ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] poll(2) with chicken: works - sort of
Jörg F. Wittenberger writes: > Anybody interested to pull this into the official chicken core? That's definitely interesting. I wonder if it would be possible to provide hooks in the core so that the scheduler can be replaced from user code? That way it would be possible to use even more efficient OS specific APIs like epoll. Or perhaps the whole issue could be side-stepped by using something like libev instead? Unsuspectingly yours, Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
[Chicken-hackers] [PATCH] Slight promise efficiency and memory improvements
Dear Chickeneers, the attached patch changes the implementation of promises to be slightly more efficient when forcing a promise more than once (one procedure call less). Also, instead of keeping the promise result in the promise thunk's closure it is now kept in a slot of the promise structure. This allows for removing the reference to the thunk once the promise has been forced and thus saving some memory. I measured its effect by running the following program with and without the patch: (define seq (let next ((n 0)) (cons n (delay (next (+ n 1)) (define (run) (print (time (let loop ((seq seq)) (if (< (car seq) 100) (loop (force (cdr seq))) (car seq) (print (memory-statistics))) (run) (run) The results of which are: without patch: 0.856s CPU time, 0.352s GC time (major), 50 mutations, 9/1539 GCs (major/minor) 50 #(268435456 230448536 1048576) 0.034s CPU time, 0/213 GCs (major/minor) 50 #(268435456 230448536 1048576) with the patch: 0.506s CPU time, 0.233s GC time (major), 50 mutations, 11/1500 GCs (major/minor) 50 #(134217728 107357264 1048576) 0.03s CPU time, 0/198 GCs (major/minor) 50 #(134217728 107357264 1048576) Hope it's of interested and not fatally flawed! Moritz >From b42464bccb2852121148c726eb49b90566d4519e Mon Sep 17 00:00:00 2001 From: Moritz Heidkamp Date: Mon, 5 Nov 2012 16:14:36 +0100 Subject: [PATCH] Make promises slightly more efficient and less memory intensive Instead of keeping the promise result in the promise thunk's closure the implementation is changed to keep the result in a slot of the promise structure. This allows for removing the reference to the thunk once the promise has been forced and thus saving some memory. --- library.scm | 28 ++-- 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/library.scm b/library.scm index 438004a..1711b84 100644 --- a/library.scm +++ b/library.scm @@ -341,8 +341,15 @@ EOF (define (##sys#force promise) (if (##sys#structure? promise 'promise) - ((##sys#slot promise 1)) - promise) ) + (apply ##sys#values + (or (##sys#slot promise 2) + (let ((results (##sys#call-with-values (##sys#slot promise 1) (lambda xs xs + (or (##sys#slot promise 2) + (begin + (##sys#setslot promise 1 #f) + (##sys#setslot promise 2 results) + results) + promise)) (define force ##sys#force) @@ -4708,22 +4715,7 @@ EOF ;;; Promises: (define (##sys#make-promise proc) - (let ([result-ready #f] - [results #f] ) -(##sys#make-structure - 'promise - (lambda () - (if result-ready - (apply ##sys#values results) - (##sys#call-with-values - proc - (lambda xs - (if result-ready - (apply ##sys#values results) - (begin - (set! result-ready #t) - (set! results xs) - (apply ##sys#values results) ) ) ) ) ) ) ) ) ) + (##sys#make-structure 'promise proc #f)) (define (promise? x) (##sys#structure? x 'promise) ) -- 1.7.12 ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] Slight promise efficiency and memory improvements
Quick follow-up: I posted the benchmark results of a different program, of course, one with the sequence going up to 50 rather than 100. Sorry for the blunder! :-) ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] Slight promise efficiency and memory improvements
Peter Bex writes: > Very clever! I've tested and pushed this. Cool, thank you very much! > Are you actually using promises so much that you're running into > performance issues with them, or was this just for fun? I ran into memory leaks when trying to implement the lazy-seq egg based on promises. And IIRC that was due to references that were kept in the delay thunk's closure and thus weren't garbage collected. The record-based implementation I came up with instead is what inspired me to check whether the same could be applied to core. I'm now evaluating whether using this promise implementation actually works for lazy-seq and whether it yields any performance benefits. One drawback is that it needs to support multi values whereas my hand-rolled version in lazy-seq doesn't. I can post a follow-up here once I've tried it if you're interested. Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
[Chicken-hackers] [PATCH] Fix TO argument check in subvector procedure
See commit message for details >From f08fc812501e9d2e5ee7e3b2154642255bedaa66 Mon Sep 17 00:00:00 2001 From: Moritz Heidkamp Date: Wed, 2 Jan 2013 22:02:10 +0100 Subject: [PATCH] Fix TO argument check in subvector procedure The subvector procedure checked its TO argument as if it was inclusive. However, its default value is the passed vector's length so it must be exclusive which also corresponds with the implementation. In effect, the erroneous check prevented producing a subvector including the given vector's last element. This patch changes the TO argument check to be exclusive and adds some test cases for the subvector procedure. --- library.scm | 2 +- tests/library-tests.scm | 8 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/library.scm b/library.scm index 5ed1e24..46cfe49 100644 --- a/library.scm +++ b/library.scm @@ -1391,7 +1391,7 @@ EOF (j (or j len)) (len2 (fx- j i))) (##sys#check-range i 0 len 'subvector) -(##sys#check-range j 0 len 'subvector) +(##sys#check-range j 0 (fx+ len 1) 'subvector) (let ((v2 (make-vector len2))) (do ((k 0 (fx+ k 1))) ((fx>= k len2) v2) diff --git a/tests/library-tests.scm b/tests/library-tests.scm index c385c1b..2d88321 100644 --- a/tests/library-tests.scm +++ b/tests/library-tests.scm @@ -420,4 +420,10 @@ ;;; message checks for invalid strings -(assert-fail (##sys#message "123\x00456")) \ No newline at end of file +(assert-fail (##sys#message "123\x00456")) + +;;; vector procedures + +(assert (equal? '#(2 3) (subvector '#(1 2 3) 1))) +(assert (equal? '#(2) (subvector '#(1 2 3) 1 2))) +(assert (equal? '#()(subvector '#(1 2 3) 1 1))) -- 1.8.0.2 ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] Updating stability...
Jim Ursetto writes: > [ ... a lot ... ] I just wanted to thank you guys for going through this hassle, it's really appreciated. I will try to help in the next stabililty cycle! Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] stability/4.8.0 test release available
Jim Ursetto writes: > I've uploaded a test distribution tarball of stability/4.8.0 [1]. This > should contain everything > that will go into 4.8.0.1 unless we find a problem. If anyone would like to > test it, > it would be appreciated. Looks good here, all my programs still do their job so far. Thanks again! Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] substring function and bounds checks
Hi Michele, Michele La Monaca writes: > Maybe this is not the right list for that, sorry. yeah, this one probably better fits chicken-users as it's not really about Chicken's implementation, so you might be losing some broader audience by posting it here. No problemo, though! > In fact, it makes the usage of substring "unsafe" and the > countermeasures I can imagine (manual bounds checks, padding, writing > my-own-substring-function, whatever) are quite unsatisfactory... to me > at least. I felt the same when coming to Scheme (from Ruby in my case). But after having been immersed in the langauge and community surrounding it for a while now I came to see it in a different light: What might look like impracticality at the beginning turns out to be a virtue in its own right. All languages you cite (well, apart from Python perhaps, as Peter noted) are from the DWIM-most-of-the-time spectrum which give a lot of leeway. This often leads to what Olin Shivers vividly describes as 80% solutions in the preamble of the SRE announcement (see http://www.scsh.net/docu/post/sre.html). I recommend you to read that one if you don't already know it. Scheme as a whole tries to aim for the 100% solutions (whether it's successful in that endeavor is open for debate, of course). That's why you'll often see functions reduced to their bare minimum purpose and correct behavior even in edge cases. This is especially true for functions defined in the standard core such as the one you are referring to. The nice thing is that from that solid core as a foundation we can build libraries which allow us to be a bit more sloppy when we want to whereas it's much harder to go the other way around. It may sound a bit like "just drink the Kool-Aid" but what I'm trying to say is: Scheme, as any language, has its own culture and you will be much happier when you try to embrace it rather than trying to impose concepts from other languages on it. But you probably already know this, so I hope my comment on the specific case of your substring issue is of help, anyway :-) Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
[Chicken-hackers] [PATCH] Small improvement for the inline egg
Fellow Chickeneers, thanks to Felix mentioning it yesterday, I checked out the inline egg today. I think it's really neat, I recommend you to check it out, too, if you didn't, yet. I only noticed two things: 1. It dumps compilation results in ~/.cache by default. This, however, is a bit like dumping stuff in /usr/share so I think it would be better to make this ~/.cache/chicken-inline or something. 2. It does a redundant check for existence of the cache directory (remember the create-directory discussion a few days back) and doesn't create missing parent directories. This patch changes / fixes these things. Felix, feel free to apply or ignore it if you think it's silly :-) Thanks Moritz Index: inline.scm === --- inline.scm (revision 28291) +++ inline.scm (working copy) @@ -39,7 +39,7 @@ (define (inline-eval x . o) (inline-compile x (if (pair? o) (car o) "") #t)) -(define-constant default-inline-cache-name ".cache") +(define-constant default-inline-cache-name ".cache/chicken-inline") (define windows-shell (foreign-value "C_WINDOWS_SHELL" bool)) (define inline-cache (make-parameter default-inline-cache-name)) @@ -94,7 +94,6 @@ (zero? (system (sprintf "cmp -s ~A ~A" (qs a) (qs b ))) (define (ensure-cache) - (unless (file-exists? (inline-cache)) -(create-directory (inline-cache)) ) ) + (create-directory (inline-cache) #t) ) ) ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] Small improvement for the inline egg
Hello again, Moritz Heidkamp writes: > 1. It dumps compilation results in ~/.cache by default. This, however, >is a bit like dumping stuff in /usr/share so I think it would be >better to make this ~/.cache/chicken-inline or something. Mario just pointed out to me in #chicken that the current default is actually ".cache", not "~/.cache". It just happened to be that I ran csi from my home when trying it out and then I didn't properly read the code when hacking up the patch. Considering that this default directory is apparently meant as a relative path I propose the attached new version which sets it to ".chicken-inline" by default. Moritz Index: inline.scm === --- inline.scm (revision 28291) +++ inline.scm (working copy) @@ -39,7 +39,7 @@ (define (inline-eval x . o) (inline-compile x (if (pair? o) (car o) "") #t)) -(define-constant default-inline-cache-name ".cache") +(define-constant default-inline-cache-name ".chicken-inline") (define windows-shell (foreign-value "C_WINDOWS_SHELL" bool)) (define inline-cache (make-parameter default-inline-cache-name)) @@ -94,7 +94,6 @@ (zero? (system (sprintf "cmp -s ~A ~A" (qs a) (qs b ))) (define (ensure-cache) - (unless (file-exists? (inline-cache)) -(create-directory (inline-cache)) ) ) + (create-directory (inline-cache) #t) ) ) ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
[Chicken-hackers] [PATCH] Make typed-records compatible with pre-typed Chickens
Hi Felix, the attached patch makes the typed-records egg compatible with pre-typed Chicken versions. It does so by importing the type-stubs module (http://wiki.call-cc.org/eggref/4/type-stubs). Thus, code depending on typed-records can transparently work with Chicken versions before 4.7.5. I also took the liberty to convert the tests to (use test) and make them report the test result via exit code. I'd be very thankful for applying the patch because my persistent-hash-map egg uses typed-records to great avail but I'd have to put in quite a bit of cond-expanding to make it compatible with older Chickens while typed-records with my patch applied requires zero code changes to make it work. I hope you agree on the utility of this :-) Best wishes Moritz Index: tests/run.scm === --- tests/run.scm (revision 28181) +++ tests/run.scm (working copy) @@ -1,12 +1,18 @@ run.scm - run tests for typed-records.scm -(use setup-api) +(use setup-api test) -(run (csi -s t.scm)) +(test-group "interpreted" + (run (csi -s t.scm))) -(compile -s -specialize t.scm) -(load "t.so") +(when (version>=? (chicken-version) "4.7.5") + (test-group "compiled with specialization" +(compile -s -specialize t.scm) +(load "t.so"))) -(compile -s t.scm -o t2.so) -(load "t2.so") +(test-group "compiled without specialization" + (compile -s t.scm -o t2.so) + (load "t2.so")) + +(test-exit) Index: tests/t.scm === --- tests/t.scm (revision 28181) +++ tests/t.scm (working copy) @@ -1,9 +1,8 @@ t.scm - tests for typed-records.scm -(use typed-records) +(use typed-records type-stubs test) - (define-record point x (y : number)) @@ -29,8 +28,11 @@ ((_ t x) (cond-expand (compiling - (compiler-typecase x - (t 'ok))) + (test 'ok + (compiler-typecase x +(t 'ok) +(* 'wrong) +(else 'ok (else #f) (let ((pt (make-point 1 2)) @@ -47,8 +49,9 @@ (let ((p (make-person age: 33))) #+compiling (compiler-typecase (person-age p) - (fixnum 'ok)) -(assert (= 33 (person-age p + (fixnum 'ok) + (else 'wrong)) +(test-assert (= 33 (person-age p ) @@ -77,5 +80,5 @@ (define x (create-bar943 1)) -(assert (eq? 1 (bar943-a x))) -(assert (eq? 42 (bar943-b x))) +(test-assert (eq? 1 (bar943-a x))) +(test-assert (eq? 42 (bar943-b x))) Index: typed-records.meta === --- typed-records.meta (revision 28181) +++ typed-records.meta (working copy) @@ -4,7 +4,8 @@ (category misc) (license "BSD") (doc-from-wiki) - (depends defstruct (chicken "4.7.5")) + (depends defstruct type-stubs) + (test-depends test) (author "felix winkelmann") (files "typed-records.scm" "typed-records.meta" "typed-records.setup" "tests/run.scm")) Index: typed-records.scm === --- typed-records.scm (revision 28181) +++ typed-records.scm (working copy) @@ -9,7 +9,8 @@ (rename chicken (define-record-type define-record-type1) (define-record define-record1)) - (rename defstruct (defstruct defstruct1))) + (rename defstruct (defstruct defstruct1)) +type-stubs) (import-for-syntax srfi-1 chicken) ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] ab bug or not a bug
Hi Jörg, Jörg F. Wittenberger writes: >>--> procedure type that is declared to modify locally held state where are you quoting this from? The wiki states the (correct) opposite: "procedure type that is declared not to modify locally held state" see http://wiki.call-cc.org/man/4/Types Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] software-type and software-version for android
Christian Kellermann writes: > Probably android for both, since android does not come with all > posix things. pthreads for example. That's not quite true, is it? See https://android.googlesource.com/platform/prebuilts/ndk/+/master/8/platforms/android-9/arch-arm/usr/include/pthread.h I vote for software-type unix, too, although it is unclear to me what this actually means :-) POSIX compliance can't be sufficient factor as Windows has that, too. Unix [tm] can't be as well as that would disqualify Linux. Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
[Chicken-hackers] [PATCH] Make quasiquote extensible with custom handlers
Fellow Chickeneers, find attached a patch which allows user code to hook into the quasiquote code expander. "What good can come from that?" you might ask. Let me elaborate! As you know, Chicken supports custom reader extensions via set-read-syntax! and friends. This is all fine unless you try to add custom read syntax for compound data structures. One example of those are SRFI 10 reader constructors which are also supported by core Chicken. Let me give you an example how they work: #;1> (define-record point x y) #;2> (define-reader-ctor 'point make-point) #;3> '#,(point 10 20) # #;4> (point-x #3) 10 #;5> (point-y #3) 20 That's pretty straight forward. Now try this: #;6> `#,(point ,(+ 5 5) 20) # #;7> (point-x #6) (unquote (+ 5 5)) Oops, not quite what we'd expect! Now, this problem was also discovered in 2004 by Bradd W. Szonye (see http://srfi.schemers.org/srfi-10/post-mail-archive/msg0.html), alas it was in the post-finalization phase of SRFI 10 and unfortunatley it doesn't seem like there was much interest in that anymore then. So I went ahead and tried to come up with a solution for that problem. What I think is needed for this to work is to be able to hook into the quasiquote expander (as noted above). The result of that is the attached patch. It allows us to do this: #;8> (define-quasiquote-handler point? (lambda (r walk n p) (list (r 'make-point) (walk (point-x p) n) (walk (point-y p) n #;9> `#,(point ,(+ 5 5) 20) # #;10> (point-x #9) 10 I think this kind of mechanism is something we should have in order to provide proper support for custom read syntax and to make SRFI 10 syntax behave as expected. Let me know if you have any suggestions for improving the API (not sure if quasiquote-handler is the best name for this kind of thing) or implementation (I don't know whether we need to pass the `n' argument to handlers or if we can hide it in a closure, for example). Also I'm not sure about where to put the code (maybe define-quasiquote-handler should not live in expand.scm). Thanks! Moritz >From b4c197c93c94bbfbab781e81a058d5fc3ad90f0a Mon Sep 17 00:00:00 2001 From: Moritz Heidkamp Date: Thu, 21 Feb 2013 18:53:08 +0100 Subject: [PATCH] Make quasiquote extensible with custom handlers This patch introduces the define-quasiquote-handler form which allows hooking into the quasiquote walker, allowing custom reader extensions for compound data literals (such as SRFI 10 reader constructors) to properly support unquoting. --- expand.scm | 29 +++-- tests/reader-tests.scm | 11 +++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/expand.scm b/expand.scm index b278ec0..8677eff 100644 --- a/expand.scm +++ b/expand.scm @@ -35,7 +35,9 @@ macro-alias check-for-multiple-bindings d dd dm dx map-se - lookup check-for-redef) + lookup check-for-redef + quasiquote-handler-ref + quasiquote-handlers) (not inline ##sys#syntax-error-hook ##sys#compiler-syntax-hook ##sys#toplevel-definition-hook)) @@ -1241,6 +1243,26 @@ (car (cdr (cdr b))) ) ) bindings) ) ) ) ) ) ) ) ) + +(define quasiquote-handlers + (list)) + +(define (define-quasiquote-handler pred handler) + (set! quasiquote-handlers +(if handler +(cons (cons pred handler) quasiquote-handlers) +(let loop ((qh quasiquote-handlers)) + (cond ((null? qh) '()) +((eq? (caar qh) pred) (loop (cdr qh))) +(else (cons (car qh) (loop (cdr qh) + +(define (quasiquote-handler-ref x) + (let loop ((qh quasiquote-handlers)) +(and (pair? qh) + (if ((caar qh) x) + (cdar qh) + (loop (cdr qh)) + (##sys#extend-macro-environment 'quasiquote '() @@ -1251,7 +1273,10 @@ (%unquote-splicing (r 'unquote-splicing))) (define (walk x n) (simplify (walk1 x n))) (define (walk1 x n) - (cond ((vector? x) + (cond ((quasiquote-handler-ref x) => + (lambda (handle) + (handle r walk n x))) + ((vector? x) `(##sys#list->vector ,(walk (vector->list x) n)) ) ((not (pair? x)) `(##core#quote ,x)) (else diff --git a/tests/reader-tests.scm b/tests/reader-tests.scm index 894e846..58ad4c5 100644 --- a/tests/reader-tests.scm +++ b/tests/reader-tests.scm @@ -23,3 +23,14 @@ (assert (string=? output "hi\nfoo\nbaz\nbye\n")) (assert (string=? " ." (with-input-from-string "\x20\u0020\U0020\056" read-all))) + + +(define-record foo bar) +(define-reader-ctor 'foo make-foo) +(define-quasiquote-handler foo? + (lambda (rename walk n x) +(list (rename 'make-foo) + (walk (foo-bar x) n + +(assert (= 1 (foo-bar '#,(foo 1 +(assert (= 3 (foo-bar `#,(foo ,(+ 1 2) -- 1.8.1.4 ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
[Chicken-hackers] Taming the egg versioning wilderness
Fellow Chickeneers, I just had the following problem (again): I tagged a new version of the lowdown egg (0.0.6). While doing so I realized that the previous tag (0.0.5) still installed itself as 0.0.4 via the install-extension invocation in its .setup file. This lead me to think over the whole situation of how we deal with egg versioning and I found it pretty error-prone and inconvenient for both users and authors. Sticking to my example: 1) Users get confused because if they run chicken-install lowdown (or even chicken-install lowdown:0.0.5), chicken-status will afterwards tell them that 0.0.4 is installed in this case. 2) Authors have to be vigilant to always keep three places in sync: The version in the .setup file (another issue here is that each invocation of install-extension and install-program require the version to be passed -- hopefully it's always the same one), the version in the .release-info file and (if a VCS is used, which is usually the case) the version in the tag name. It may of course be that I misunderstand some intentions of the versioning system as it is (e.g. why it is possible to install multiple extensions and programs with differing versions from within an egg which itself can have yet another differing version). If that's the case I'd be happy to be enlightened about it! Otherwise I'd suggest to somehow get rid of at least the versions in the .setup file. Maybe it would be possible to make them optional and use the egg's version as a default in this case? Let me know what your thoughts are on this issue. I am happy to try to come up with a patch should we agree on how to proceed. Thanks! Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] Taming the egg versioning wilderness
Hi Mario, Mario Domenech Goulart writes: > I don't know exactly how to simplify this situation, so I'll comment on > how detect those errors. > > [... lots of useful advice ...] thanks for that, this will definitely help to make maintenance less of a pain in the meantime unless one forgets to do the salmonella dance :-) It would be better if we wouldn't have to worry about these problems to begin with, though, or would you disagree? Thanks again! Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] software-type and software-version for android
Christian Kellermann writes: >> That's not quite true, is it? See >> https://android.googlesource.com/platform/prebuilts/ndk/+/master/8/platforms/android-9/arch-arm/usr/include/pthread.h > > Ah the NDK... Right, and the NDK is practically the only way to integrate Chicken with Android as far as I know, i.e. in order to build Chicken for Android you need to use the NDK toolchain. So this is not tangential, is it? > Ok, instead of doing further guesswork, I checked the source. Well > the software type is used to branch off to do system dependend > things in csc (generate a manifest for windows), in eval.scm to do > the windows dll loading dance. So if you want to support android > and will do different things while compiling (providing a correct > manifest etc.) having a distinct 'android type still makes more > sense to me than declaring it all unix. Android is definitely not > unix at all. I don't really understand the distinction between the two values from their use in the code, actually. For example, in eval.scm ##sys#load-library-extension dispatches on both software-type and software-version for seemingly the same purpose (granted, it does have a comment saying "this is crude..."). In csc.scm, software-type is (as you pointed out) to check whether a manifest is to be generated on Windows but OTOH software-version is checked for whether to generate ELF binaries. This doesn't seem like fundamentally different things to me, so I'm a bit confused now. Maybe Felix can enlighten us? :-) Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] Taming the egg versioning wilderness
Mario Domenech Goulart writes: >> thanks for that, this will definitely help to make maintenance less of a >> pain in the meantime unless one forgets to do the salmonella dance :-) >> It would be better if we wouldn't have to worry about these problems to >> begin with, though, or would you disagree? > > I totally agree. I just don't know a simple way to do that, keeping > things backward-compatible and so on. Yeah, that's tricky. I will try to come up with a patch to make the version argument of install-extension and install-program optional. This should be backwards compatible unless I'm missing something! Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] ab bug or not a bug
Jörg F. Wittenberger writes: > In any case, it seems inconsistent. > > (DOM -> RND : TYPE) for predicates I'd expect to be pure. Wrong? Agreed, predicates should be pure. Not sure what the intention is here! Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] Taming the egg versioning wilderness
Moritz Heidkamp writes: > Yeah, that's tricky. I will try to come up with a patch to make the > version argument of install-extension and install-program optional. This > should be backwards compatible unless I'm missing something! OK, having thought about it some more this doesn't work, of course, as eggs which leave off the version argument would not be compatible with older Chickens. I am now thinking that it would probably be better to provide an extension that can be used in .setup files to read the egg version from the .release-info file and then pass it on to install-extension and install-program. Kon, maybe this would make sense as an addition to setup-helpers? Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
[Chicken-hackers] [PATCH] Reimplement topological-sort with cycle detection
Fellow Chickeneers, I recently noticed that Chicken's topological-sort function does not detect cycles in the passed graph. Initially I ventured into patching this functionality into the existing implementation which originates from SLIB. This turned out to be tricky as it is a heavily imperative implemenatation. By the time I had figured out how it works I had already opened the relevant chapter of Introduction to Algorithms. According to the header comment of the SLIB implementation (see http://cvs.savannah.gnu.org/viewvc/slib/slib/tsort.scm?revision=1.2) it is also based on that algorithm, but apparently without the cycle detection (or maybe it wasn't in the 1st edition which is what the author used, while I used the 3rd edition). Eventually I found it easier to reimplement the algorithm in a functinal style to add the cycle detection bit. One thing I'm not sure about is how I raise the condition in case a cycle is detected. Comments on that are very welcome! Have a nice Sunday Moritz >From 840b24477b38f1ca3815248ae9704911bd8527b0 Mon Sep 17 00:00:00 2001 From: Moritz Heidkamp Date: Sun, 3 Mar 2013 13:28:20 +0100 Subject: [PATCH] Reimplement topological-sort with cycle detection --- data-structures.scm | 85 ++--- 1 file changed, 41 insertions(+), 44 deletions(-) diff --git a/data-structures.scm b/data-structures.scm index 56944ec..d51abe4 100644 --- a/data-structures.scm +++ b/data-structures.scm @@ -707,52 +707,49 @@ (sort! (append seq '()) less?))) -;;; Simple topological sort: -; -; Taken from SLIB (slightly adapted): Copyright (C) 1995 Mikael Djurfeldt +;;; Topological sort with cycle detection: +;; +;; A functional implementation of the algorithm described in Cormen, +;; et al. (2009), Introduction to Algorithms (3rd ed.), pp. 612-615. (define (topological-sort dag pred) - (if (null? dag) - '() - (let* ((adj-table '()) - (sorted '())) - - (define (insert x y) - (let loop ([at adj-table]) - (cond [(null? at) (set! adj-table (cons (cons x y) adj-table))] - [(pred x (caar at)) (set-cdr! (car at) y)] - [else (loop (cdr at))] ) ) ) - - (define (lookup x) - (let loop ([at adj-table]) - (cond [(null? at) #f] - [(pred x (caar at)) (cdar at)] - [else (loop (cdr at))] ) ) ) - - (define (visit u adj-list) - ;; Color vertex u - (insert u 'colored) - ;; Visit uncolored vertices which u connects to - (for-each (lambda (v) - (let ((val (lookup v))) - (if (not (eq? val 'colored)) - (visit v (or val '()) - adj-list) - ;; Since all vertices downstream u are visited - ;; by now, we can safely put u on the output list - (set! sorted (cons u sorted)) ) - - ;; Hash adjacency lists - (for-each (lambda (def) (insert (car def) (cdr def))) - (cdr dag)) - ;; Visit vertices - (visit (caar dag) (cdar dag)) - (for-each (lambda (def) - (let ((val (lookup (car def - (if (not (eq? val 'colored)) - (visit (car def) (cdr def) - (cdr dag)) - sorted) ) ) + (define (visit dag node edges path state) +(case (alist-ref node (car state) pred) + ((grey) + (##sys#abort +(##sys#make-structure + 'condition + '(exn cycle) + `((exn . message) "cycle detected" + (exn . arguments) ,(list (cons node (reverse path))) + (exn . call-chain) ,(##sys#get-call-chain) + (exn . location) topological-sort + ((black) + state) + (else + (let walk ((edges (or edges (alist-ref node dag pred '( + (state (cons (cons (cons node 'grey) (car state)) + (cdr state + (if (null? edges) + (cons (alist-update! node 'black (car state) pred) + (cons node (cdr state))) + (let ((edge (car edges))) + (walk (cdr edges) + (visit dag +edge +#f +(cons edge path) +state + (let loop ((dag dag) + (state (cons (list) (list +(if (null? dag) +(cdr state) +(loop (cdr dag) + (visit dag + (caar dag) + (cdar dag) + '() + state) ;;; Binary search: -- 1.8.1.4 ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] Reimplement topological-sort with cycle detection
Moritz Heidkamp writes: > One thing I'm not sure about is how I raise the condition in case a > cycle is detected. Comments on that are very welcome! Right, forgot to include an example: #;1> (topological-sort '((a b) (b c) (c a)) eq?) Error: (topological-sort) cycle detected: (a b c a) As you can see it includes a hint about the cyclic path. Only the first cycle detected is reported currently. Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] ##sys#double->number gone; intetional?
Hi Jörg, Jörg F. Wittenberger writes: > I found that ##sys#double->number is gone from library.scm . > > Still it's there in chicken.h . Mistake or intended? > At least I'd consider it worth a news item. the ##sys# API is not even documented so I don't think it needs to be mentioned in the NEWS. In fact, AFIUI the point of identifiers having that prefix (and ##core#) is that those can be changed without considering backwards compatibility. Otherwise they could just be exported without the prefix. Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] strange error message, please help with interpretation
Hi Jörg, Jörg F. Wittenberger writes: > So how would I interpret this message. As far as I can see, this > tells me that somehow a typecheck failed on a (struct ) > testing it to be a (struct ) -- which would have been supposed > to succeed. > > Am I missing something I think your assessment is correct. Unfortunately, I don't have the slightest clue what might be the cause of this either. I assume you are not using ##sys#make-structure or anything to create instances of that record type but only the "proper" constructor? Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH 1/2] write: escape DEL character in strings
Hi guys, Peter Bex writes: > On Tue, Mar 05, 2013 at 06:48:44PM +0100, Florian Zumbiehl wrote: > Thanks for this (and the other) patch! Here's a signed-off version, > which other team members may push. I also nominate this patch for > inclusion in the stability branch. thanks a lot, signed off and pushed! Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] testcase -strict-types
John Cowan writes: > Jörg F. Wittenberger scripsit: > >> Note: in local procedure `doloop9', >> in toplevel procedure `foo#bar': >> (strcttps.scm:10) in procedure call to `null?', the predicate is >> called with an argument of type >> `null' and will always return true > > That strikes me as Just Wrong. Even if a predicate is known to always > succeed, it shouldn't be impossible to call it, any more than it should > be impossible to call a predicate that always returns #t on any argument. Note that it's just a "Note", though :-) I think it's sensible to show this as it might indeed point to some unnecessary / redundant check that could just as well be removed. Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] testcase -strict-types
Hi Jörg, Jörg F. Wittenberger writes: > Note: in local procedure `doloop9', > in toplevel procedure `foo#bar': > (strcttps.scm:10) in procedure call to `null?', the predicate is > called with an argument of type > `null' and will always return true gcc strcttps.c -o strcttps.o -c > -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H > -DC_ENABLE_PTABLES -Os -fomit-frame-pointer -I"/usr/include/chicken" > rm strcttps.c gcc strcttps.o -o strcttps -L"/usr/lib" -Wl,-R"/usr/lib" > -lchicken -lm -ldl rm strcttps.o $ ./strcttps gaga The "Note" points to the problem I think: The specializer seems to just replace your null? check with #t as can be seen when compiling the program like this: $ csc -debug 3 -strict-types strcttps.scm The output contains this: (if #t (k225 'gaga) (k225 foobar8)) I'm not sure how -strict-types could lead to this result. Maybe the type declaration for null? is flawed somehow? Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] testcase -strict-types
Peter Bex writes: > As I understand it, strict-types declares variables to never change > their types. So once it's looked at the initial declaration of the > variable, it assigns it a type of null, and then it can never change. > > -strict-types assume variable do not change their type > > The set! would change the type from NULL to LIST (or maybe PAIR), > invalidating that assumption. Ah, very good, that should explain it. I somehow had it remembered as "assume functions are always called with correctly typed arguments" or something. Should have RTFM :-) Thanks! Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] testcase -strict-types
Jörg F. Wittenberger writes: > Though in a way the explanation is correct. -strict-types assumes > '() to be null from the initialization. Short of a way to declare > the type of foobar as (list-of ) this fails when it's used > as the initial and correct value of type (list-of ) with > zero length. You should be able to use `the' or `assume' for that purpose. > What the optimizer should do is to see into the doloop and notice > the ambiguous type null being refined to a list. Given that the description of -strict-types is "assume variable do not change their type" I think the behavior is correct. > Find attached two more variants. strcttps2.scm, which convinces > chicken to do the right thing, ans strcttps2.scm, which fails > the other way around. Right, here you initialize the variable's type with list (or pair, I don't know what's detected) and then possible change it to null while never checking with null? on the whole list but only on the rest. Looks fine from what I can tell! Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] testcase -strict-types
Jörg F. Wittenberger writes: > [1. text/plain] > > On Mar 25 2013, Moritz Heidkamp wrote: > >>Jörg F. Wittenberger writes: >>> Though in a way the explanation is correct. -strict-types assumes >>> '() to be null from the initialization. Short of a way to declare >>> the type of foobar as (list-of ) this fails when it's used >>> as the initial and correct value of type (list-of ) with >>> zero length. >> >>You should be able to use `the' or `assume' for that purpose. > > Where would I find "the" respective "assume" to be documented? In the manual page about the type system, e.g. http://wiki.call-cc.org/man/4/Types > (Would the syntax break standard Scheme compatibility?) They are regular Scheme syntax so you can stub them. You could use http://wiki.call-cc.org/eggref/4/type-stubs for other Schemes, too (it is intended to be used with older Chickens). Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] Restore row and column counting for ports (fixes #978)
Jim Ursetto writes: > Unfortunately, I think it is essentially impossible at this time to > have the compiler do this automatically via type analysis. I believe > it is possible to get the compiler to treat string ports, for example, > as a separate type and specialize on that. However, once you do this, > you cannot use the existing procedures (such as close-input-port) > which specialize on plain input-ports and output-ports, as there's no > way to say that a particular type (string-input-port) is derived from > another type (input-port) and is valid in lieu of the base type. Doesn't (define-type string-input-port input-port) work here? Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
[Chicken-hackers] [PATCH] Make tests work from symlinked paths
The private repository path tests didn't work when run from inside a path containing symlinks because runtests.sh didn't expand symlinks while the -private-repository mechanism does. This lead the test assertion which compares the two paths to fail. >From 464869bde8c7d70af42cc7b9530181bb78698370 Mon Sep 17 00:00:00 2001 From: Moritz Heidkamp Date: Sat, 25 May 2013 01:46:02 +0200 Subject: [PATCH] Make tests work from symlinked paths The private repository path tests didn't work when run from inside a path containing symlinks because runtests.sh didn't expand symlinks while the -private-repository mechanism does. This lead the test assertion which compares the two paths to fail. --- tests/runtests.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/runtests.sh b/tests/runtests.sh index 931e2f2..c49cac5 100755 --- a/tests/runtests.sh +++ b/tests/runtests.sh @@ -389,8 +389,8 @@ $compile -e embedded3.c embedded4.scm echo " private repository test ..." mkdir -p tmp $compile private-repository-test.scm -private-repository -o tmp/xxx -tmp/xxx $PWD/tmp -PATH=$PWD/tmp:$PATH xxx $PWD/tmp +tmp/xxx `realpath -- "$PWD"`/tmp +PATH=$PWD/tmp:$PATH xxx `realpath -- "$PWD"`/tmp # this may crash, if the PATH contains a non-matching libchicken.dll on Windows: #PATH=$PATH:$PWD/tmp xxx $PWD/tmp rm -fr rev-app rev-app-2 reverser/*.import.* reverser/*.so -- 1.8.2.3 ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] Make tests work from symlinked paths
Mario Domenech Goulart writes: >> Ah good catch, but unfortunately OpenBSD does not expose realpath >> as a shell command (or binary utility). Is there a way to do this >> portably? John, do you know? > > Maybe "readlink -f" ? Thanks, that works, as well! Attached is an updated patch. Moritz >From 2c9bbb077165ffc171411376a0f68e6ba6adf9f2 Mon Sep 17 00:00:00 2001 From: Moritz Heidkamp Date: Sat, 25 May 2013 01:46:02 +0200 Subject: [PATCH] Make tests work from symlinked paths The private repository path tests didn't work when run from inside a path containing symlinks because runtests.sh didn't expand symlinks while the -private-repository mechanism does. This lead the test assertion which compares the two paths to fail. --- tests/runtests.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/runtests.sh b/tests/runtests.sh index 931e2f2..6a1d0e3 100755 --- a/tests/runtests.sh +++ b/tests/runtests.sh @@ -389,8 +389,8 @@ $compile -e embedded3.c embedded4.scm echo " private repository test ..." mkdir -p tmp $compile private-repository-test.scm -private-repository -o tmp/xxx -tmp/xxx $PWD/tmp -PATH=$PWD/tmp:$PATH xxx $PWD/tmp +tmp/xxx `readlink -f -- "$PWD"`/tmp +PATH=$PWD/tmp:$PATH xxx `readlink -f -- "$PWD"`/tmp # this may crash, if the PATH contains a non-matching libchicken.dll on Windows: #PATH=$PATH:$PWD/tmp xxx $PWD/tmp rm -fr rev-app rev-app-2 reverser/*.import.* reverser/*.so -- 1.8.2.3 ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] Make tests work from symlinked paths
Mario Domenech Goulart writes: > Maybe "readlink -f" ? OK, Peter found that even that is not portable so I changed the test itself to do the path canonicalization. Turns out that while the posix unit's read-symbolic-link has a CANONICALIZE option it doesn't quite behave like the readlink(1) program. So I went ahead and adapted its behavior to match that. I also noticed that the types.db entry for read-symbolic-link did not include that optional argument so I took it as an opportunity to fix this, as well. Moritz >From e98ed45bcfeca57d8d0a293da4ee335ea8d1ff4b Mon Sep 17 00:00:00 2001 From: Moritz Heidkamp Date: Sat, 25 May 2013 17:08:09 +0200 Subject: [PATCH 1/3] Improve read-symbolic-link canonicalization Passing #t for the CANONICALIZE option of read-symbolic-link now behaves like the --canonicalize option of readlink(1), i.e. it recursively follows every symlink in every component of the given path. When called like this, read-symbolic-link like readlink(1) now verifies that all components exist. --- posixunix.scm | 43 +-- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/posixunix.scm b/posixunix.scm index a2776da..6cdb4ef 100644 --- a/posixunix.scm +++ b/posixunix.scm @@ -1241,21 +1241,36 @@ EOF (define-foreign-variable _filename_max int "FILENAME_MAX") -(define read-symbolic-link +(define ##sys#read-symbolic-link (let ((buf (make-string (fx+ _filename_max 1 -(lambda (fname #!optional canonicalize) - (##sys#check-string fname 'read-symbolic-link) - (let ((len (##core#inline - "C_do_readlink" - (##sys#make-c-string (##sys#expand-home-path fname) 'read-symbolic-link) buf))) - (if (fx< len 0) - (if canonicalize - fname - (posix-error #:file-error 'read-symbolic-link "cannot read symbolic link" fname)) - (let ((pathname (substring buf 0 len))) - (if (and canonicalize (symbolic-link? pathname)) - (read-symbolic-link pathname 'canonicalize) - pathname ) ) ) ) ) ) ) +(lambda (fname location) + (let ((len (##core#inline + "C_do_readlink" + (##sys#make-c-string fname location) buf))) +(if (fx< len 0) +(posix-error #:file-error location "cannot read symbolic link" fname) +(substring buf 0 len)) + +(define (read-symbolic-link fname #!optional canonicalize) + (##sys#check-string fname 'read-symbolic-link) + (let ((fname (##sys#expand-home-path fname))) +(if canonicalize +(receive (base-origin base-directory directory-components) (decompose-directory fname) + (let loop ((components directory-components) + (result (string-append (or base-origin "") (or base-directory "" +(if (null? components) +result +(let ((pathname (make-pathname result (car components + (if (file-exists? pathname) + (loop (cdr components) +(if (symbolic-link? pathname) +(let ((target (##sys#read-symbolic-link pathname 'read-symbolic-link))) + (if (absolute-pathname? target) + link + (make-pathname result target))) +pathname)) + (##sys#signal-hook #:file-error 'read-symbolic-link "could not canonicalize path with symbolic links, component does not exist" pathname)) +(##sys#read-symbolic-link fname 'read-symbolic-link (define file-link (let ([link (foreign-lambda int "link" c-string c-string)]) -- 1.8.2.3 >From a7de20ed3d344f9fcaa981fd746091624869be60 Mon Sep 17 00:00:00 2001 From: Moritz Heidkamp Date: Sat, 25 May 2013 17:27:55 +0200 Subject: [PATCH 2/3] Fix read-symbolic-link types.db entry The optional CANONICALIZE argument was missing. --- types.db | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types.db b/types.db index 01d84e2..c061092 100644 --- a/types.db +++ b/types.db @@ -1765,7 +1765,7 @@ (prot/none fixnum) (prot/read fixnum) (prot/write fixnum) -(read-symbolic-link (#(procedure #:clean #:enforce) read-symbolic-link (string) string)) +(read-symbolic-link (#(procedure #:clean #:enforce) read-symbolic-link (string #!optional boolean) string)) (regular-file? (#(procedure #:clean #:enforce) regular-file? ((or string fixnum)) boolean)) (seconds->local-time (#(procedure #:clean #:enforce) seconds->local-time (#!optional number) (vector fixnum fixnum fixnum fixnum fixnum fixnum fixnum fixnum boolean fixnum))) (seconds->string (#(procedure #:clean #:enforce) seconds->string (#!optional number) string)) -- 1.8.2.3 >From a3cea67616c7d50092e20374ebc47176c7fee660 Mon Sep 17 00:0
Re: [Chicken-hackers] [PATCH] Add support for R7RS named characters and string escapes (except hex escapes)
Peter Bex writes: >> The attached patch supplements Peter's to handle these cases. > > I've signed this off, and added a few test cases for this as well. > Find this version attached. Tested, signed off and pushed. Thanks! Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] Fix #892 by causing panic instead of crash/segfault upon heap exhaustion
Hi Peter, Peter Bex writes: > I remembered that normally when going out of memory, we get a "heap full > while resizing" panic. Attached is an even simpler patch which removes > the (seemingly bogus?) check whether the new size equals the old size, > and will simply carry on reclaiming, thereby triggering the familiar > error message. This should simplify matters a bit. good job finding the root cause of this issue! Tests still pass and the reproduction case from the ticket terminates with a sensible error now. As far as I can tell the change is good and thus I signed it off and pushed it. Thanks! Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] Simplify and correct C_SIXTY_FOUR check (fix #979)
Peter Bex writes: > I've tested this change on NetBSD/amd64 with GCC and LLVM/Clang, > and on Linux/i386 with GCC. I'd appreciate it if people on other > platforms/compilers (especially Windows and OS X) could test this. Works fine on Linux/x86_64 with both GCC (4.8.1) and Clang (3.3), too. Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] Simplify and correct C_SIXTY_FOUR check (fix #979)
Peter Bex writes: > I've tested this change on NetBSD/amd64 with GCC and LLVM/Clang, > and on Linux/i386 with GCC. I'd appreciate it if people on other > platforms/compilers (especially Windows and OS X) could test this. Since no further make check results came in we decided to push it now. But keep the results coming anyway. You can just use the current master version (37cf50fe7f4dd2335fa330ab9538d245f1f58a06) now. Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] Fix -no-parentheses-synonyms and -no-symbol-escapes
Hey there, Peter Bex writes: > Here's a fix for this, with some regression tests to ensure this won't > break again. > > I've hopefully simplified it enough to make it "obviously correct". > I also noticed that even after correcting the test, pipes occurring > inside symbols were still allowed, so I've also fixed this by adding > an additional check (the "sep" check was wrong so I ripped it out). sorry for the delay! I just tested, reviewed, and pushed this one. Thanks a lot for improving CHICKEN, guys :-) We should probably get rid of the "unterminated string" message in case it's actually an unterminated symbol at some point but this is not very important IMHO. Have a nice day! Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] Another subtle GC problem
Hi, Peter Bex writes: > I decided to take another look at the GC in an attempt to > understand it better, and found yet another iffy line of code: > > When comparing the heap growth to the current heap size plus > the stack size, two unsigned quantities are subtracted from > eachother (size is a C_uword parameter to C_rereclaim2, > heap_size is a size_t, which is also unsigned), and then > compared to be less than stack_size * 2. > > If the heap is not growing, but shrinking, this unsigned > subtraction will underflow and cause it to result in a > huge value. This happens to work, but I think the attached > patch makes it more explicit what's really happening: it > only does the subtraction and comparison when the new size > is bigger than the old heap size (so we're growing the heap, > due to memory pressure). looks OK and works fine AFAICT. Pushed! > When shrinking the heap, this check won't need to be run because > we've just done a GC, so there *should be* no pressure on > the nursery, so it won't get copied to the heap. But I don't > fully grok this part yet, so don't take my word for it. So this would get rid of one comparsion operation per major GC? I'd guess this is negligible, no? Thanks! Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] Use noreturn attribute in clang versions which support it
Hi, Peter Bex writes: > Fixing this got rid of all the warnings, except one, which exposed > a small bug which is also a minor inefficiency: C_2_divide will call > C_fix() on an integer value, which in case of flonums will not be > initialised. In cases of flonums, it will be initialised, but it will > get C_fix()ed and immediately C_unfix()ed afterwards. This is > unnecessary and wrong, so I've moved the C_fix() call to occur after > the check. I tried compiling the old master with clang and got lots of warnings which disappeared after applying your patch. Very nice! Signed off and pushed. BTW, I got another warning when running the tests: ../chicken 'embedded4.scm' -output-file 'a.c' -scrutinize -verbose -include-path .. 'clang' 'a.c' -o 'a.o' -c -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H -DC_ENABLE_PTABLES -g -Wall -Wno-unused -DC_EMBEDDED -I.. -I"/home/syn/code/public/chicken/core/target/include/chicken" 'clang' 'embedded3.c' -o 'embedded3.o' -c -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H -DC_ENABLE_PTABLES -g -Wall -Wno-unused -DC_EMBEDDED -I.. -I"/home/syn/code/public/chicken/core/target/include/chicken" embedded3.c:23:26: warning: format specifies type 'unsigned int' but the argument has type 'long' [-Wformat] printf("data: %08x\n", val); ^~~ %08lx Not sure if this is something to worry about, though. > Perhaps this patch can also go into stability. It's not important, > but probably a good idea so users compiling with clang won't get > spurious warnings. Jim? > Sorry if this mail is a little rambling, I'm slightly ill right now. Sorry to hear that, get well soon! Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] Treat lone carriage returns as line endings in ##sys#scan-buffer-line
Peter Bex writes: > Ah, very good! > > I have nothing to comment on this, so I'm just attaching them as-is, > plus a signed-off-by line, so the next guy can just sign it off and > push. :) > > Thanks! Thanks from me as well, I've pushed the patches and closed the ticket. Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] Fix #566 and simplify/improve flonum printing code
Hi Peter, Peter Bex writes: > > In order to fix #566, I decided it's much easier to rip out the > HAVE_GCVT definition in Cygwin. After testing on several platforms, > it turns out that gcvt() is really not required, and it's deprecated > by POSIX as well. So we should probably stop using it anyway; this > also simplifies testing as it doesn't needlessly use different library > functions on different platforms. > > I tried to figure out why HAVE_GCVT was introduced in the first place, > but it goes all the way back to the very first commit in the NonGNU CVS > even. Felix mentioned that he seemed to recall that it had something > to do with making behaviour of the various Windows builds consistent > among eachother. > > However, I've tested all three Windows builds, and they all behave > equally well (or better) with s[n]printf() instead of gcvt(). We no > longer have a MSVC build, so the original problem probably was there, > or it was in an older version of Cygwin/MingW which has been fixed in > the meanwhile (it's been over 10 years, so a thing or two will have > changed there, as well!). If we ever regain a MSVC build, we can > look at restoring this code, but in the meanwhile I prefer the > simplicity of this solution. I was even able to get rid of the > MINGW hack just below the changed code! wow, thanks going through all that trouble! Shedding some light on dusty corners like that is definitely a good idea to keep the code clean and to improve it, too. > I've also taken the opportunity to convert sprintf into a checked > snprintf. I'm not 100% sure but I don't think this requires a CVE > since you can't easily (at all?) cause over 4096 flonum digits to > get printed, and flonum-print-precision is rarely, if ever > user-controlled. Feel free to request a CVE if you disagree. I'm not sure about this either. I've pushed the patch though as it looks OK to me and all tests pass, too. I also grepped for "gcvt" afterwards and couldn't find traces of it anymore. Good riddance! Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] Ticket 942 - make install uses user's umask
Peter Bex writes: > Thanks guys, for making and testing the patch! > > Here's a proper git patch w/ changelog. Thanks from me, too. Signed off and pushed! Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
[Chicken-hackers] [PATCH] Add proper list checks to assq/assv/assoc and memq/memv/member
Fellow Chickeneers, please see the commit message of the attached patch for details! Cheers Moritz >From 16396c41c63699e261f108af4cf48e15eb54bdde Mon Sep 17 00:00:00 2001 From: Moritz Heidkamp Date: Tue, 21 Jan 2014 12:20:11 +0100 Subject: [PATCH] Add proper list checks to assq/assv/assoc and memq/memv/member Previously it was possible to pass any kind of value to these procedures as their list argument and they would just return #f in that case. This patch adds checks to the checked variants at the end of the loop so it will only incur additional runtime cost if either a non-list is passed as the list argument or if the sought element is not found. Note that this patch has the side-effect of also erroring out on improper lists in the not-found case. This lead to an error getting raised in the scrutinizer which is taken care of in this patch, too. Furthermore, the test cases added for all procedures affected by this patch uncovered a bug in the specializations defined for assq, assv, and assoc in types.db which would specialize to the unsafe inlined variant of assq for any kind of list rather than lists of pairs. This is also fixed. --- runtime.c | 18 ++ scrutinizer.scm | 2 +- tests/library-tests.scm | 35 +++ types.db| 6 +++--- 4 files changed, 57 insertions(+), 4 deletions(-) diff --git a/runtime.c b/runtime.c index c90b9dd..58dde49 100644 --- a/runtime.c +++ b/runtime.c @@ -5518,6 +5518,9 @@ C_regparm C_word C_fcall C_i_assq(C_word x, C_word lst) lst = C_u_i_cdr(lst); } + if(lst!=C_SCHEME_END_OF_LIST) +barf(C_BAD_ARGUMENT_TYPE_ERROR, "assq", lst); + return C_SCHEME_FALSE; } @@ -5537,6 +5540,9 @@ C_regparm C_word C_fcall C_i_assv(C_word x, C_word lst) lst = C_u_i_cdr(lst); } + if(lst!=C_SCHEME_END_OF_LIST) +barf(C_BAD_ARGUMENT_TYPE_ERROR, "assv", lst); + return C_SCHEME_FALSE; } @@ -5556,6 +5562,9 @@ C_regparm C_word C_fcall C_i_assoc(C_word x, C_word lst) lst = C_u_i_cdr(lst); } + if(lst!=C_SCHEME_END_OF_LIST) +barf(C_BAD_ARGUMENT_TYPE_ERROR, "assoc", lst); + return C_SCHEME_FALSE; } @@ -5567,6 +5576,9 @@ C_regparm C_word C_fcall C_i_memq(C_word x, C_word lst) else lst = C_u_i_cdr(lst); } + if(lst!=C_SCHEME_END_OF_LIST) +barf(C_BAD_ARGUMENT_TYPE_ERROR, "memq", lst); + return C_SCHEME_FALSE; } @@ -5589,6 +5601,9 @@ C_regparm C_word C_fcall C_i_memv(C_word x, C_word lst) else lst = C_u_i_cdr(lst); } + if(lst!=C_SCHEME_END_OF_LIST) +barf(C_BAD_ARGUMENT_TYPE_ERROR, "memv", lst); + return C_SCHEME_FALSE; } @@ -5599,6 +5614,9 @@ C_regparm C_word C_fcall C_i_member(C_word x, C_word lst) if(C_equalp(C_u_i_car(lst), x)) return lst; else lst = C_u_i_cdr(lst); } + + if(lst!=C_SCHEME_END_OF_LIST) +barf(C_BAD_ARGUMENT_TYPE_ERROR, "member", lst); return C_SCHEME_FALSE; } diff --git a/scrutinizer.scm b/scrutinizer.scm index 020949d..e29e847 100644 --- a/scrutinizer.scm +++ b/scrutinizer.scm @@ -2029,7 +2029,7 @@ t)) ((eq? 'deprecated (car t)) (and (= 2 (length t)) (symbol? (second t)) t)) - ((or (memq '--> t) (memq '-> t)) => + ((and (list? t) (or (memq '--> t) (memq '-> t))) => (lambda (p) (let* ((cleanf (eq? '--> (car p))) (ok (or (not rec) (not cleanf diff --git a/tests/library-tests.scm b/tests/library-tests.scm index 5418fbb..df0639f 100644 --- a/tests/library-tests.scm +++ b/tests/library-tests.scm @@ -541,3 +541,38 @@ A (assert (equal? '#(2 3) (subvector '#(1 2 3) 1))) (assert (equal? '#(2) (subvector '#(1 2 3) 1 2))) (assert (equal? '#()(subvector '#(1 2 3) 1 1))) + +;;; alist accessors + +(assert (equal? '(foo) (assq 'foo '((foo) +(assert (not (assq 'foo '( +(assert-fail (assq 'foo '(bar))) +(assert-fail (assq 'foo 'bar)) + + +(assert (equal? '(foo) (assv 'foo '((foo) +(assert (not (assv 'foo '( +(assert-fail (assv 'foo '(bar))) +(assert-fail (assv 'foo 'bar)) + +(assert (equal? '("foo") (assoc "foo" '(("foo") +(assert (not (assoc "foo" '( +(assert-fail (assoc "foo" '("bar"))) +(assert-fail (assoc "foo" "bar")) + +;;; list membership + +(assert (equal? '(foo) (memq 'foo '(bar foo +(assert (not (memq 'foo '(bar +(assert (not (memq 'foo '( +(assert-fail (memq 'foo 'foo)) + +(assert (equal? '(foo) (memv 'foo '(bar foo +(assert (not (memv 'foo '(bar +(assert (not (memv 'foo '( +(assert-fail (memv 'foo 'foo)) + +(assert (equal? '("foo") (memb
Re: [Chicken-hackers] [PATCH] Add proper list checks to assq/assv/assoc and memq/memv/member
Hey Peter, Peter Bex writes: > Thanks for this one. thanks for reviewing! > You somehow missed C_i_memv, though, which resulted in library-tests > to fail. So at least the tests are complete :) Hm, that's weird, I was sure I had given it a final run. Anyway, I might be missing something but my patch actually does cover C_i_memv (lines 73-82), doesn't it? AFAICT you added another check to C_u_i_memq, referring to memv in the error message. But isn't the point of C_u_* variants to be unchecked? Note that I made a bootstrap build before running the tests. Maybe that's why the tests didn't fail for me? Thanks again and cheers! Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] Fix validation for multiple-return procedure types
Evan Hanson writes: > Please see the patch for an explanation. For the record: The error addressed by this patch came up in building the r7rs egg as we didn't have test cases for this particular procedure type declaration, yet. Thanks a lot, Evan, it looks and works well. Signed off and pushed! Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] Fix problem building "git" egg
Hi, Peter Bex writes: > The attached patch is simple, I hope it's also correct: it only calls > assq if there really is any info, otherwise just fall through. > I'm not 100% sure whether this is the correct fix, because I don't > really understand this code. works well, make check still passes and the git egg now builds again. Thanks a lot, I pushed it. > Maybe it should complain that the extension doesn't (yet) exist, > because it hasn't been installed at that point? In that case, the > check should be pulled into the "cond" check like so: > > ((and (memq id ##sys#explicit-library-modules) > (##sys#extension-information id 'require-extension)) > => (lambda (info) >(let ((nr (assq 'import-only info)) > (s (assq 'syntax info))) > ...))) Not sure about this one. Apparently the git egg works even like this so maybe such a complaint is not really necessary? Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
[Chicken-hackers] [PATCH] Remove list argument check from C_u_i_memq
This was erroneously added in 0a52536b7cb6b3d5a35ecc8f4c11131041ae873a >From 32bc17d3c3a313a4f869079f3777ed7dd2b8b9f4 Mon Sep 17 00:00:00 2001 From: Moritz Heidkamp Date: Wed, 5 Feb 2014 23:26:39 +0100 Subject: [PATCH] Remove list argument check from C_u_i_memq This was erroneously added in 0a52536b7cb6b3d5a35ecc8f4c11131041ae873a --- runtime.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/runtime.c b/runtime.c index 9575d80..f184d71 100644 --- a/runtime.c +++ b/runtime.c @@ -5600,9 +5600,6 @@ C_regparm C_word C_fcall C_u_i_memq(C_word x, C_word lst) else lst = C_u_i_cdr(lst); } - if(lst!=C_SCHEME_END_OF_LIST) -barf(C_BAD_ARGUMENT_TYPE_ERROR, "memv", lst); - return C_SCHEME_FALSE; } -- 1.8.5.2 ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [Chicken-users] Testers wanted; iOS patch
Hi! On 15. März 2014 16:59:13 MEZ, Kon Lovett wrote: > >On Mar 15, 2014, at 4:41 AM, Peter Bex wrote: > >> Hi all, >> >> Attached is a patch by Bevuta which Felix sent last X-mas. It adds >> rudimentary support for iOS through a target Makefile. I've so far >been >> unable to test this because I don't have an iOS device. I don't have >> access to a Mac, so I'm unable to verify that this patch even builds. >> >> I've asked Moritz, but he's extremely busy these days, so perhaps >> someone else is able to test this patch in the meanwhile? Indeed, and I was on vacation this week, too. I hope to manage trying it with our code on Monday finally. >Looks like "tcp.scm" has moved past the state when the patch was >created. Needs "3-way" & manual resolution. I have a new version of this patch on my machine which applies cleanly again (Felix already reviewed it). I'll post it here when I'm back at it! Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [Chicken-users] Testers wanted; iOS patch
Hi again, Moritz Heidkamp writes: > I have a new version of this patch on my machine which applies cleanly > again (Felix already reviewed it). I'll post it here when I'm back at > it! find it attached! Moritz >From 4064075061189c7b743b69ebbacad82a089c5c34 Mon Sep 17 00:00:00 2001 From: felix Date: Thu, 19 Dec 2013 11:02:06 +0100 Subject: [PATCH] Added basic iOS support. --- Makefile.ios | 111 ++ README| 32 +++ distribution/manifest | 1 + tcp.scm | 33 --- 4 files changed, 171 insertions(+), 6 deletions(-) create mode 100644 Makefile.ios diff --git a/Makefile.ios b/Makefile.ios new file mode 100644 index 000..dff7875 --- /dev/null +++ b/Makefile.ios @@ -0,0 +1,111 @@ +# Makefile.ios - configuration for Apple iOS -*- Makefile -*- +# +# Copyright (c) 2013, The Chicken Team +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following +# conditions are met: +# +# Redistributions of source code must retain the above copyright notice, this list of conditions and the following +# disclaimer. +# Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided with the distribution. +# Neither the name of the author nor the names of its contributors may be used to endorse or promote +# products derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS +# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY +# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + + +ifneq ($(CONFIG),) +include $(CONFIG) +endif + +SRCDIR = ./ + +# platform configuration + +# for simulator: ARCH ?= i386 +ARCH ?= armv7 +XCODE_PATH ?= /Applications/Xcode.app +XCODE_DEVELOPER ?= $(XCODE_PATH)/Contents/Developer +# for Xcode 4: XCODE_TOOLPATH ?= $(XCODE_DEVELOPER)/Toolchains/XCodeDefault.xctoolchain/usr/bin +XCODE_TOOLPATH ?= $(XCODE_DEVELOPER)/usr/bin +# for simulator: XCODE_SDK ?= $(XCODE_DEVELOPER)/Platforms/iPhoneSimulator.platform/Developer/SDKs/ipHoneSimulator7.0.sdk +XCODE_SDK ?= $(XCODE_DEVELOPER)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk +STATICBUILD = 1 +HACKED_APPLY = + +# options + +# for Xcode 4: C_COMPILER ?= $(XCODE_DEVELOPER)/Platforms/iPhoneOS.platform/iPhoneOS.platform/Developer/usr/bin +C_COMPILER ?= $(XCODE_TOOLPATH)/gcc +LIBRARIAN ?= $(XCODE_DEVELOPER)/Platforms/iPhoneOS.platform/Developer/usr/bin/ar +C_COMPILER_OPTIONS ?= -no-cpp-precomp -fno-strict-aliasing -fwrapv -fno-common -DHAVE_CHICKEN_CONFIG_H -mno-thumb -isysroot $(XCODE_SDK) -arch $(ARCH) +ifdef DEBUGBUILD +C_COMPILER_OPTIMIZATION_OPTIONS ?= -g -Wall -Wno-unused +else +ifdef OPTIMIZE_FOR_SPEED +C_COMPILER_OPTIMIZATION_OPTIONS ?= -O3 -fomit-frame-pointer +else +C_COMPILER_OPTIMIZATION_OPTIONS ?= -Os -fomit-frame-pointer +endif +endif +LIBRARIAN_OPTIONS = scru +ASSEMBLER_OPTIONS = +LINKER_OPTIONS = -isysroot $(XCODE_SDK) -arch $(ARCH) + +# special files + +CHICKEN_CONFIG_H = chicken-config.h + +# select default and internal settings + +include $(SRCDIR)/defaults.make + +chicken-config.h: chicken-defaults.h + echo "/* GENERATED */" >$@ + echo "#define HAVE_DIRENT_H 1" >>$@ + echo "#define HAVE_INTTYPES_H 1" >>$@ + echo "#define HAVE_LIMITS_H 1" >>$@ + echo "#define HAVE_LONG_LONG 1" >>$@ + echo "#define HAVE_MEMMOVE 1" >>$@ + echo "#define HAVE_MEMORY_H 1" >>$@ + echo "#define HAVE_POSIX_POLL 1" >>$@ + echo "#define HAVE_SIGACTION 1" >>$@ + echo "#define HAVE_SIGSETJMP 1" >>$@ + echo "#define HAVE_SIGPROCMASK 1" >>$@ + echo "#define HAVE_STDINT_H 1" >>$@ + echo "#define HAVE_STDLIB_H 1" >>$@ + echo "#define HAVE_STRERROR 1" >>$@ + echo "#define HAVE_STRINGS_H 1" >>$@ + echo "#define HAVE_STRING_H 1" >>$@ + echo "#define HAVE_STRTOLL 1" >>$@ + echo "#define HAVE_STRTOQ 1" >>$@ + echo &quo
Re: [Chicken-hackers] [Chicken-users] Testers wanted; iOS patch
Kon Lovett writes: > If I am to be one of the two then my suggestion is to begin the > release process w/o this patch. Don't believe I will be able to > generate a test case that soon. (Sorry, have looming releases.) I've finally gotten around to testing it with our application and (as it seems to work fine) pushed the patch into master. It would still be good to have a second tester, of course, so if you are still inclined to give it a try that would be great! Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] Consolidate NEWS for 4.9.0
Hi Peter Peter Bex writes: > Here's a patch which consolidates the NEWS file for the upcoming > 4.9.0 release. Please also cherry-pick (or merge?) it into the > prerelease branch after importing it! > > I've also added notes for the Android and iOS support; we forgot > about that when support for these platforms was added. thank you very much, Peter. I've pushed the patch with a slight clarification of the resizable call trace buffer item as discussed on IRC. I've also merged the resulting master into the prerelease branch one more time which now also includes Mario's recent manual update as well as the removal of FILE_INFO_SIZE which I deemed safe enough. Cheers Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] incorrect warning during compilation
Hi, Felix Winkelmann writes: > So, I can't think of a solution that answers all of your questions. > I would go with the scheme-pointer. > > We could add another foreign type, that accepts strings but doesn't > copy. I'll look into that. how about extending the [nonnull-]scheme-pointer type to be parameterizable like [nonnull-]c-pointer so that Kristian could use (scheme-pointer char) for his case? Would that be possible somehow? Moritz -- bevuta IT GmbH - professionelle IT-Lösungen Marktstraße 10 | http://www.bevuta.com/ | HRB 62476 AG Köln 50968 Köln | Tel.: +49 221 282678-0 | Geschäftsführer: Pablo Beyen ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
[Chicken-hackers] [PATCH 1/2] Set HAVE_POSIX_POLL for Android
Hi everyone, the attached patch enables poll(2) for the Android platform. I verified via strace on an Android device that poll(2) is actually used after the patch. A preliminary NEWS entry is included but needs to be updated once we have a CVE number for this issue. Moritz -- bevuta IT GmbH - professionelle IT-Lösungen Marktstraße 10 | http://www.bevuta.com/ | HRB 62476 AG Köln 50968 Köln | Tel.: +49 221 282678-0 | Geschäftsführer: Pablo Beyen >From c902019d70e4389c447f39152e71e1ddfd58395b Mon Sep 17 00:00:00 2001 From: Moritz Heidkamp Date: Mon, 4 Aug 2014 15:19:48 +0200 Subject: [PATCH 1/2] Set HAVE_POSIX_POLL for Android --- Makefile.android | 1 + NEWS | 3 +++ 2 files changed, 4 insertions(+) diff --git a/Makefile.android b/Makefile.android index 819587f..ac72ee8 100644 --- a/Makefile.android +++ b/Makefile.android @@ -69,6 +69,7 @@ chicken-config.h: chicken-defaults.h echo "#define HAVE_LONG_LONG 1" >>$@ echo "#define HAVE_MEMMOVE 1" >>$@ echo "#define HAVE_MEMORY_H 1" >>$@ + echo "#define HAVE_POSIX_POLL 1" >>$@ echo "#define HAVE_SIGACTION 1" >>$@ echo "#define HAVE_SIGSETJMP 1" >>$@ echo "#define HAVE_STDINT_H 1" >>$@ diff --git a/NEWS b/NEWS index 20ece38..b854f8d 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ 4.9.1 +- Security fixes + - Use POSIX poll() on Android (CVE pending). + - Core libraries - alist-ref from unit data-structures now gives an error when passed a non-list, for consistency with assv/assq/assoc. -- 1.9.4 ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH 1/2] Set HAVE_POSIX_POLL for Android
Moritz Heidkamp writes: > the attached patch enables poll(2) for the Android platform. Forgot to mention that I think this should probably go into stability. Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
[Chicken-hackers] [PATCH 2/2] Invert poll(2) flag default
The attached patch is a follow-up to my previous patch (the one which enables poll(2) on Android). It inverts the HAVE_POSIX_POLL flag to HAVE_NO_POSIX_POLL which only needs to be set when poll(2) is *not* available rather than the other way around. The purpose is to make the safe choice the default. Since this is merely intended to make future changes less likely to accidentally disable poll(2) it doesn't need to be included in the stability branch. I've tested the patch on Linux x86_64 only. Even though it's a rather trivial patch it would probably be good to also test this on at least one of the Windows platforms just in case. Any takers? Thanks to Florian Zumbiehl for the idea for this patch. Moritz -- bevuta IT GmbH - professionelle IT-Lösungen Marktstraße 10 | http://www.bevuta.com/ | HRB 62476 AG Köln 50968 Köln | Tel.: +49 221 282678-0 | Geschäftsführer: Pablo Beyen >From 05a5743437e255ca3402b8a56ec69c1d6b2b8f90 Mon Sep 17 00:00:00 2001 From: Moritz Heidkamp Date: Mon, 4 Aug 2014 15:23:13 +0200 Subject: [PATCH 2/2] Invert poll(2) flag default To be on the safe side we now assume that poll(2) is available by default and define the HAVE_NO_POSIX_POLL flag in case it isn't available on a platform. --- Makefile.aix | 1 - Makefile.android | 1 - Makefile.bsd | 1 - Makefile.cross-linux-mingw | 1 + Makefile.cygwin| 1 - Makefile.haiku | 1 - Makefile.hurd | 1 - Makefile.ios | 1 - Makefile.linux | 1 - Makefile.macosx| 1 - Makefile.mingw | 1 + Makefile.mingw-msys| 1 + Makefile.solaris | 1 - runtime.c | 4 ++-- scheduler.scm | 2 +- 15 files changed, 6 insertions(+), 13 deletions(-) diff --git a/Makefile.aix b/Makefile.aix index 68b33b7..72e9715 100644 --- a/Makefile.aix +++ b/Makefile.aix @@ -74,7 +74,6 @@ chicken-config.h: chicken-defaults.h echo "#define HAVE_LONG_LONG 1" >>$@ echo "#define HAVE_MEMMOVE 1" >>$@ echo "#define HAVE_MEMORY_H 1" >>$@ - echo "#define HAVE_POSIX_POLL 1" >>$@ echo "#define HAVE_SIGACTION 1" >>$@ echo "#define HAVE_SIGSETJMP 1" >>$@ echo "#define HAVE_STDINT_H 1" >>$@ diff --git a/Makefile.android b/Makefile.android index ac72ee8..819587f 100644 --- a/Makefile.android +++ b/Makefile.android @@ -69,7 +69,6 @@ chicken-config.h: chicken-defaults.h echo "#define HAVE_LONG_LONG 1" >>$@ echo "#define HAVE_MEMMOVE 1" >>$@ echo "#define HAVE_MEMORY_H 1" >>$@ - echo "#define HAVE_POSIX_POLL 1" >>$@ echo "#define HAVE_SIGACTION 1" >>$@ echo "#define HAVE_SIGSETJMP 1" >>$@ echo "#define HAVE_STDINT_H 1" >>$@ diff --git a/Makefile.bsd b/Makefile.bsd index af28814..c69ea35 100644 --- a/Makefile.bsd +++ b/Makefile.bsd @@ -72,7 +72,6 @@ chicken-config.h: chicken-defaults.h echo "#define HAVE_LONG_LONG 1" >>$@ echo "#define HAVE_MEMMOVE 1" >>$@ echo "#define HAVE_MEMORY_H 1" >>$@ - echo "#define HAVE_POSIX_POLL 1" >>$@ echo "#define HAVE_SIGACTION 1" >>$@ echo "#define HAVE_SIGSETJMP 1" >>$@ echo "#define HAVE_SIGPROCMASK 1" >>$@ diff --git a/Makefile.cross-linux-mingw b/Makefile.cross-linux-mingw index 32a6f2f..d8951eb 100644 --- a/Makefile.cross-linux-mingw +++ b/Makefile.cross-linux-mingw @@ -95,6 +95,7 @@ chicken-config.h: chicken-defaults.h echo "#define HAVE_LONG_LONG 1" >>$@ echo "#define HAVE_MEMMOVE 1" >>$@ echo "#define HAVE_MEMORY_H 1" >>$@ + echo "#define HAVE_NO_POSIX_POLL 1" >>$@ echo "#define HAVE_STDINT_H 1" >>$@ echo "#define HAVE_STDLIB_H 1" >>$@ echo "#define HAVE_STRERROR 1" >>$@ diff --git a/Makefile.cygwin b/Makefile.cygwin index 376f6b8..f499c90 100644 --- a/Makefile.cygwin +++ b/Makefile.cygwin @@ -89,7 +89,6 @@ chicken-config.h: chicken-defaults.h echo "#define HAVE_LONG_LONG 1" >>$@ echo "#define HAVE_MEMMOVE 1" >>$@ echo "#define HAVE_MEMORY_H 1" >>$@ - echo "#define HAVE_POSIX_POLL 1" >>$@ echo "#define HAVE_SIGACTION 1" >>$@ echo "#define HAVE_STDINT_H 1" >>$@ echo "#define HAVE_STDLIB_H 1" >>$@ diff --git a/Makefile.haiku b/Makefile.haiku index a1f5841..7eeec26 100644 --- a/Makefile.haiku +++ b/Makefile.haiku @@ -66,7 +66,6 @@ chicken-config.h: chicken-defaults.h echo "#define HAVE_LONG_LONG 1" >>$@ echo "#define HAVE_MEMMOVE 1" >>$@ echo "#define HAVE_MEMORY_H 1" >>$@ - echo "#d
[Chicken-hackers] [PATCH] Don't enable debugging on Android by default
This was probably accidentally left in when generating the Android patch. -- bevuta IT GmbH - professionelle IT-Lösungen Marktstraße 10 | http://www.bevuta.com/ | HRB 62476 AG Köln 50968 Köln | Tel.: +49 221 282678-0 | Geschäftsführer: Pablo Beyen >From 8d21fae15e69c65d0b3d1e721de557588f0a4dfa Mon Sep 17 00:00:00 2001 From: Moritz Heidkamp Date: Mon, 4 Aug 2014 18:29:26 +0200 Subject: [PATCH] Don't enable debugging on Android by default --- runtime.c | 4 1 file changed, 4 deletions(-) diff --git a/runtime.c b/runtime.c index 1a68906..8608506 100644 --- a/runtime.c +++ b/runtime.c @@ -640,10 +640,6 @@ int CHICKEN_initialize(int heap, int stack, int symbols, void *toplevel) if(chicken_is_initialized) return 1; else chicken_is_initialized = 1; -#ifdef __ANDROID__ - debug_mode = 2; -#endif - if(debug_mode) C_dbg(C_text("debug"), C_text("application startup...\n")); -- 1.9.4 ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH 2/2] Invert poll(2) flag default
HI Peter, Peter Bex writes: > This seems like a good idea. However, could you also swap the two > code blocks? A double negation (#ifndef NO_...) can be confusing, and > by making it read "#ifdef NO_POSIX_POLL" (I'd probably drop the > HAVE_ prefix, as that's more idiomatic AFAICT), it becomes a little > clearer. you are right--my intention was to make the patch as non-invasive as possible so its purpose is obvious. Now that the purpose should be clear, find attached an updated version which swaps the code blocks to avoid the double negation. I also dropped the HAVE_ prefix as per your suggestion, I didn't see the other flags names like that. Thanks for the hint! Moritz >From 27097791ee5de99d52d513858b10d4e43ce0e33b Mon Sep 17 00:00:00 2001 From: Moritz Heidkamp Date: Mon, 4 Aug 2014 15:23:13 +0200 Subject: [PATCH] Invert poll(2) flag default To be on the safe side we now assume that poll(2) is available by default and define the NO_POSIX_POLL flag in case it isn't available on a platform. --- Makefile.aix | 1 - Makefile.android | 1 - Makefile.bsd | 1 - Makefile.cross-linux-mingw | 1 + Makefile.cygwin| 1 - Makefile.haiku | 1 - Makefile.hurd | 1 - Makefile.ios | 1 - Makefile.linux | 1 - Makefile.macosx| 1 - Makefile.mingw | 1 + Makefile.mingw-msys| 1 + Makefile.solaris | 1 - runtime.c | 14 ++-- scheduler.scm | 54 +++--- 15 files changed, 37 insertions(+), 44 deletions(-) diff --git a/Makefile.aix b/Makefile.aix index 68b33b7..72e9715 100644 --- a/Makefile.aix +++ b/Makefile.aix @@ -74,7 +74,6 @@ chicken-config.h: chicken-defaults.h echo "#define HAVE_LONG_LONG 1" >>$@ echo "#define HAVE_MEMMOVE 1" >>$@ echo "#define HAVE_MEMORY_H 1" >>$@ - echo "#define HAVE_POSIX_POLL 1" >>$@ echo "#define HAVE_SIGACTION 1" >>$@ echo "#define HAVE_SIGSETJMP 1" >>$@ echo "#define HAVE_STDINT_H 1" >>$@ diff --git a/Makefile.android b/Makefile.android index ac72ee8..819587f 100644 --- a/Makefile.android +++ b/Makefile.android @@ -69,7 +69,6 @@ chicken-config.h: chicken-defaults.h echo "#define HAVE_LONG_LONG 1" >>$@ echo "#define HAVE_MEMMOVE 1" >>$@ echo "#define HAVE_MEMORY_H 1" >>$@ - echo "#define HAVE_POSIX_POLL 1" >>$@ echo "#define HAVE_SIGACTION 1" >>$@ echo "#define HAVE_SIGSETJMP 1" >>$@ echo "#define HAVE_STDINT_H 1" >>$@ diff --git a/Makefile.bsd b/Makefile.bsd index af28814..c69ea35 100644 --- a/Makefile.bsd +++ b/Makefile.bsd @@ -72,7 +72,6 @@ chicken-config.h: chicken-defaults.h echo "#define HAVE_LONG_LONG 1" >>$@ echo "#define HAVE_MEMMOVE 1" >>$@ echo "#define HAVE_MEMORY_H 1" >>$@ - echo "#define HAVE_POSIX_POLL 1" >>$@ echo "#define HAVE_SIGACTION 1" >>$@ echo "#define HAVE_SIGSETJMP 1" >>$@ echo "#define HAVE_SIGPROCMASK 1" >>$@ diff --git a/Makefile.cross-linux-mingw b/Makefile.cross-linux-mingw index 32a6f2f..6e4c34a 100644 --- a/Makefile.cross-linux-mingw +++ b/Makefile.cross-linux-mingw @@ -95,6 +95,7 @@ chicken-config.h: chicken-defaults.h echo "#define HAVE_LONG_LONG 1" >>$@ echo "#define HAVE_MEMMOVE 1" >>$@ echo "#define HAVE_MEMORY_H 1" >>$@ + echo "#define NO_POSIX_POLL 1" >>$@ echo "#define HAVE_STDINT_H 1" >>$@ echo "#define HAVE_STDLIB_H 1" >>$@ echo "#define HAVE_STRERROR 1" >>$@ diff --git a/Makefile.cygwin b/Makefile.cygwin index 376f6b8..f499c90 100644 --- a/Makefile.cygwin +++ b/Makefile.cygwin @@ -89,7 +89,6 @@ chicken-config.h: chicken-defaults.h echo "#define HAVE_LONG_LONG 1" >>$@ echo "#define HAVE_MEMMOVE 1" >>$@ echo "#define HAVE_MEMORY_H 1" >>$@ - echo "#define HAVE_POSIX_POLL 1" >>$@ echo "#define HAVE_SIGACTION 1" >>$@ echo "#define HAVE_STDINT_H 1" >>$@ echo "#define HAVE_STDLIB_H 1" >>$@ diff --git a/Makefile.haiku b/Makefile.haiku index a1f5841..7eeec26 100644 --- a/Makefile.haiku +++ b/Makefile.haiku @@ -66,7 +66,6 @@ chicken-config.h: chicken-defaults.h echo "#define HAVE_LONG_LONG 1" >>$@ echo "#define HAVE_MEMMOVE 1" >>$@ echo "#define HAVE_MEMORY_H 1" >>$@ - echo "#define HAVE_POSIX_POLL 1" >>$@ echo "#define HAVE_SIGACTION 1" >>$@ echo "#define HAVE_SIG
Re: [Chicken-hackers] [PATCH 0/5] List scrutiny special cases
John Cowan writes: > Thanks, that's helpful. The trouble is that such a file is an internal > (not publicly documented, unstable) format. So if I want to ship portable > code along with type information for Chicken, I have to: > > 1) insert the type declarations in the code > > 2) compile with the -emit-type-file option > > 3) strip out the declarations again > > 4) hope the .types file continues to work with new compiler releases Wait, what? Why not just something like this: (cond-expand (chicken (include "chicken-type-decls.scm")) (else)) > That's really intolerable. I suppose if I confine myself to : and > define-type, then I could ship my code along with macros that turn them > into (begin). FTR, there is the type-stubs egg which defines those macros and some more. It's purpose is to make code compatible with CHICKENS that didn't yet have the type syntax but could be used for portability purposes, too. Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH][for chicken-5] Remove srfi-13
Mario Domenech Goulart writes: > Sorry, I haven't even thought about CRs. I just assumed we won't bother > much about breaking compatibility in CHICKEN 5 (it doesn't mean we > should gratuitously break stuff). But you have a point -- we may not > have a consensus on some decisions. How about creating CRs when such > issues arise? For example, like Peter suggests, when someones disagrees > on the list. Sounds good to me, too. FTR, I'm also in favor of extracting those modules. And thanks for all the work you guys have already put into this effort so far! Moritz ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
[Chicken-hackers] [PATCH] Fix buffer overrun in substring-index[-ci]
Dear Chickeneers, the attached patch fixes a potential buffer overrun in substring-index[-ci] I ran into today (pun intended). See commit message for details. I included a regression test but I'm not sure whether it's ideal because it adds a dependency on object-evict to the data-structures tests. Alternative ideas welcome. While I was at it I also added a range check for the start index argument and got rid of the square brackets :-) I guess this might warrant a CVE? Cheers Moritz -- bevuta IT GmbH - professional IT solutions Marktstrasse 10 | http://www.bevuta.com/ | HRB 62476 AG Cologne D-50968 Cologne | Tel.: +49 221 282678-0 | CEO: Pablo Beyen From 230eed2745ea2b57de3c9073e8596892b1da2d8c Mon Sep 17 00:00:00 2001 From: Moritz Heidkamp Date: Sun, 14 Dec 2014 23:33:52 +0100 Subject: [PATCH] Fix buffer overrun in substring-index[-ci] When passing a start index greater than 0, substring-index[-ci] would scan past the end of the subject string, leading to bogus results in case the substring is accidentally run into beyond the end of the subject. This patch fixes the issue and also adds a range check for the start index. --- data-structures.scm | 22 ++ tests/data-structures-tests.scm | 11 ++- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/data-structures.scm b/data-structures.scm index a94c163..511a3c1 100644 --- a/data-structures.scm +++ b/data-structures.scm @@ -307,15 +307,21 @@ (define (traverse which where start test loc) (##sys#check-string which loc) (##sys#check-string where loc) -(let ([wherelen (##sys#size where)] - [whichlen (##sys#size which)] ) +(let* ((wherelen (##sys#size where)) + (whichlen (##sys#size which)) + (end (fx- wherelen whichlen))) (##sys#check-exact start loc) - (let loop ([istart start] [iend whichlen]) - (cond [(fx> iend wherelen) #f] - [(test istart whichlen) istart] - [else - (loop (fx+ istart 1) - (fx+ iend 1) ) ] ) ) ) ) + (if (and (fx>= start 0) + (fx> wherelen start)) + (let loop ((istart start)) + (cond ((fx> istart end) #f) + ((test istart whichlen) istart) + (else (loop (fx+ istart 1) + (##sys#error-hook (foreign-value "C_OUT_OF_RANGE_ERROR" int) + loc + start + wherelen + (set! ##sys#substring-index (lambda (which where start) (traverse diff --git a/tests/data-structures-tests.scm b/tests/data-structures-tests.scm index 51c25a9..34ccb2f 100644 --- a/tests/data-structures-tests.scm +++ b/tests/data-structures-tests.scm @@ -1,6 +1,6 @@ data-structures-tests.scm -(use data-structures) +(use data-structures lolevel) (define-syntax assert-error (syntax-rules () @@ -57,6 +57,15 @@ (assert (< 0 (string-compare3-ci "foo\x00b" "foo\x00a"))) (assert (< 0 (string-compare3-ci "foo\x00b" "foo\x00A"))) + +;; This used to fail because substring-index and co. used to search +;; beyond the end of the subject string when a start index > 0 was +;; provided. We use object-evict to ensure that the strings are placed +;; in adjacent memory ranges so we can detect this error. +(let* ((foo (object-evict (make-string 32 #\x))) + (bar (object-evict "y"))) + (assert (not (substring-index "y" foo 30 + ;; topological-sort (assert (equal? '() (topological-sort '() eq?))) -- 2.1.3 signature.asc Description: PGP signature ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH][4][5] Add arity checks for ##core#proc-class platform rewrites
Hey Evan, On 22 March 2015 06:36 CET, Evan Hanson wrote: > Let me know if any of that was unclear. The patch against 5 is obviously > more important, but I'd like them both to go in, assuming they look OK. thanks a lot for this thorough explanation and for digging into this issue in the first place! I've reviewed the patches and they look good From my perspective, though I have to say that I don't know this part of CHICKEN very well. In fact, it was the first time I've looked into it in any detail at all, so thanks for this opportunity to learn :-) I've done bootstrap builds and ran checks on both branches, everything seemed to check out fine, so signed off and pushed! Moritz signature.asc Description: PGP signature ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [Chicken-announce] CHICKEN 4.10.0 release candidate 1 available
On 10 June 2015 20:39 CEST, Mario Domenech Goulart wrote: > I've found a small regression related to substring-index[-ci]. I hope > the attached patch fixes it. For posterity: Mario and I poked away at this one a bit more via IRC and found a few more issues. Eventually, a modified version of this patch (along with a handful of additional tests) was applied to prerelease (dde858e), master (e6723de) and chicken-5 (5de5c6e). We'll prepare a new RC soon. Thanks for all the test results so far! Moritz signature.asc Description: PGP signature ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] Ensure try-compile cleans up tempfiles (#1213)
Hi Peter, On 24 August 2015 21:52 CEST, Peter Bex wrote: > I noticed that try-compile leaves a temp.1234.o file in the current > directory when invoked (see #1213). The definition actually has a > "oname" variable, but it isn't used. So the attached patch causes it > to explicitly pass "-o ONAME" to the compiler, to ensure that it > writes to that file (which should now be created under the tempdir > instead of the current directory as an added bonus), and then removes > it. thanks for the patch, I applied it to the latest master and everything seems to work fine. I also manually tested it with a dummy egg which uses try-compile. > Perhaps we should also try adding shellpath to *target-lib-home*, but > I decided to keep this change self-contained and ask, first. I think this is a trivial and uncontroversial change, feel free to just apply it! > This change should also go into the chicken-5 branch, I think. I did that, too, using the same test as above. Moritz signature.asc Description: PGP signature ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
[Chicken-hackers] [PATCH] Fix unsafe specializations in types.db
Hi everyone, the attached patch addresses the issue explained in https://bugs.call-cc.org/ticket/1216 as well as similar ones I found by sifting through the whole of types.db, though I can't guarantee that any other instances slipped my attention, of course. The only one I'm a bit unhappy about is `move-memory!' as I couldn't find a safe inline version of it. Does anyone have a clue whether there is such a thing already? Moritz From c40e4f11abb29c6f2451656a3c09ea3272c5ddb8 Mon Sep 17 00:00:00 2001 From: Moritz Heidkamp Date: Sat, 5 Sep 2015 00:24:32 +0200 Subject: [PATCH] Fix unsafe specializations in types.db This patch fixes some specializations in types.db which could lead to unsafe code. In all cases, the specialized versions did not only elide runtime type checks but also range checks for their arguments. For example, `string-ref' could have been specialized so that it would allow for an index pointing past the end of the string to be passed. Fixes #1216. --- types.db | 20 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/types.db b/types.db index b79020c..4058872 100644 --- a/types.db +++ b/types.db @@ -551,10 +551,10 @@ ((string) (##sys#size #(1 (string-ref (#(procedure #:clean #:enforce) string-ref (string fixnum) char) - ((string fixnum) (##core#inline "C_subchar" #(1) #(2 + ((string fixnum) (##core#inline "C_i_string_ref" #(1) #(2 (string-set! (#(procedure #:enforce) string-set! (string fixnum char) undefined) - ((string fixnum char) (##core#inline "C_setsubchar" #(1) #(2) #(3 + ((string fixnum char) (##core#inline "C_i_string_set" #(1) #(2) #(3 (string-append (#(procedure #:clean #:enforce) string-append (#!rest string) string) ((string string) (##sys#string-append #(1) #(2 @@ -731,7 +731,7 @@ (arithmetic-shift (#(procedure #:clean #:enforce) arithmetic-shift (number number) number)) (bit-set? (#(procedure #:clean #:enforce) bit-set? (number fixnum) boolean) - ((fixnum fixnum) (##core#inline "C_u_i_bit_setp" #(1) #(2 + ((fixnum fixnum) (##core#inline "C_i_bit_setp" #(1) #(2 (bitwise-and (#(procedure #:clean #:enforce) bitwise-and (#!rest number) number) ((fixnum fixnum) (fixnum) @@ -1488,19 +1488,7 @@ (make-record-instance (#(procedure #:clean) make-record-instance (symbol #!rest) *)) (make-weak-locative (#(procedure #:clean #:enforce) make-weak-locative (* #!optional fixnum) locative)) -(move-memory! (#(procedure #:enforce) move-memory! (* * #!optional fixnum fixnum fixnum) *) - ((pointer pointer fixnum) - (##core#inline "C_copy_ptr_memory" #(2) #(1) #(3) '0 '0)) - ((pointer pointer fixnum fixnum) - (##core#inline "C_copy_ptr_memory" #(2) #(1) #(3) '0 #(4))) - ((pointer pointer fixnum fixnum fixnum) - (##core#inline "C_copy_ptr_memory" #(2) #(1) #(3) #(5) #(4))) - ((locative locative fixnum) - (##core#inline "C_copy_ptr_memory" #(2) #(1) #(3) '0 '0)) - ((locative locative fixnum fixnum) - (##core#inline "C_copy_ptr_memory" #(2) #(1) #(3) '0 #(4))) - ((locative locative fixnum fixnum fixnum) - (##core#inline "C_copy_ptr_memory" #(2) #(1) #(3) #(5) #(4 +(move-memory! (#(procedure #:enforce) move-memory! (* * #!optional fixnum fixnum fixnum) *)) (mutate-procedure! (#(procedure #:enforce) mutate-procedure! (procedure (procedure (procedure) . *)) procedure)) -- 2.4.6 signature.asc Description: PGP signature ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
[Chicken-hackers] Fix
Hi everyone, char-ready? on string input ports would return #f when they've reached the end of their underlying string. However, char-ready? is supposed to return #t in this case. The attached patch fixes this and adds a corresponding regression test. It applies to both master and chicken-5. Cheers Moritz >From 0fb9dd6eb4f9380e6ef44cf4ee2030e1f11ef412 Mon Sep 17 00:00:00 2001 From: Moritz Heidkamp Date: Fri, 14 Apr 2017 16:22:39 +0200 Subject: [PATCH] Fix char-ready? on EOF for string input ports char-ready? on string input ports would return #f when they've reached the end of their underlying string. However, char-ready? is supposed to return #t in this case. --- library.scm | 3 +-- tests/port-tests.scm | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/library.scm b/library.scm index 3caba429..51d6793b 100644 --- a/library.scm +++ b/library.scm @@ -4255,8 +4255,7 @@ EOF (##sys#setislot p 10 (fx+ position len)) ) ) ) void ; close (lambda (p) #f) ; flush-output - (lambda (p) ; char-ready? - (fx< (##sys#slot p 10) (##sys#slot p 11)) ) + (lambda (p) #t) ; char-ready? (lambda (p n dest start) ; read-string! (let* ((pos (##sys#slot p 10)) (n2 (fx- (##sys#slot p 11) pos) ) ) diff --git a/tests/port-tests.scm b/tests/port-tests.scm index ec6a323b..463e31e6 100644 --- a/tests/port-tests.scm +++ b/tests/port-tests.scm @@ -42,6 +42,8 @@ EOF (read-line p))) (assert (= 20 (length (read-lines (open-input-string *text*) +(assert (char-ready? (open-input-string ""))) + (let ((out (open-output-string))) (test-equal "Initially, output string is empty" (get-output-string out) "") -- 2.12.0 ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] Fix segfault in get-environment-variable and three C compiler warnings
Hi Peter, I tested building again with your patch and the warnings are now gone. Pushed :-) Moritz -- bevuta IT GmbH Marktstrasse 10 | http://www.bevuta.com/ | HRB 62476 AG Cologne D-50968 Cologne | Tel.: +49 221 282678-0 | CEO: Pablo Beyen ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers