Moritz Heidkamp | 20 Apr 23:37 2015
Picon

ANN: Comparse documentation gains an example section

Dear Chickeneers,

by popular request I've just updated the Comparse documentation to
include an example section. As of now it contains a walk-through example
of creating a parser for RFC 3339 timestamps [1]. I aim to write up
another example over next few days.

Hope you like it!

Moritz

[1] http://wiki.call-cc.org/eggref/4/comparse#rfc-3339-timestamps --
    Note that there is an RFC 3339 parser egg already (plainly called
    rfc3339). However, it doesn't perform any validation like the
    example parser does.
_______________________________________________
Chicken-users mailing list
Chicken-users <at> nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users
Caolan McMahon | 20 Apr 22:34 2015
Picon

TOML parser egg

Hi all,

I've been writing a TOML parser, mostly as an excuse to play with
comparse (with is very nice btw). TOML is a reasonable looking config
file format that's not crazy like YAML ;)

The egg is available at http://github.com/caolan/chicken-toml

More info on TOML: https://github.com/toml-lang/toml

If someone could add this to the egg index I'd appreciate it.

I tried to keep the API close to the medea JSON parser. It's passing
the toml-test suite and should be pretty usable. The encoder produces
'correct' but not necessarily pretty output. Expect the formatting of
the TOML output to change as I make it more human-friendly in future
versions (eg, deciding when to use multi-line strings).

Enjoy!

Caolan
Matt Welland | 19 Apr 16:52 2015
Picon

Bounty: update chicken-iup to all latest versions US$200

I need chicken-iup brought up to date and in the process canvas-draw fixed.

I'm advertising this on Craigslist in case there is a starving student looking to make a buck by playing around on a computer:
The offer is of course open to anyone so I thought I'd post it to chicken-users in spite of my zero success track record with bounties :)

Let me know if interested.

Thanks.
_______________________________________________
Chicken-users mailing list
Chicken-users <at> nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users
Matt Welland | 11 Apr 18:00 2015
Picon

how to use readline with (repl) to add repl to my programs?


With 3.0 this fails due to toplevel-command not found:

(use readline apropos)
(import readline)
(import apropos)
(current-input-port (make-readline-port))
(install-history-file #f "/.csi.history")
(repl)

With 1.993 this worked:

(use readline apropos)
(import readline)
(import apropos)
(gnu-history-install-file-manager
         (string-append
          (or (get-environment-variable "HOME") ".") "/.megatest_history"))
(current-input-port (make-gnu-readline-port "megatest> "))
;; (current-input-port (make-readline-port))
;; (install-history-file #f "/.csi.history")
(repl)

Adding (import csi) doesn't help as I guess toplevel-command is not exported and defining a procedure:

(define (toplevel-command . a) #f)
(use readline)

works but it seems wrong. Also, calling (repl) works to give a repl but none of the toplevel , calls are there.

Any help on how to make toplevel calls available in a repl much appreciated. BTW, this feature of megatest (being able to extend it and use a repl) has been incredibly useful. Just one more thing to love about scheme and chicken in particular.
_______________________________________________
Chicken-users mailing list
Chicken-users <at> nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users
Andy Bennett | 8 Apr 12:28 2015

Fix date-literals to build & install date-literals.import.so

Hi,

NhanH reported in IRC that they could not get the date-literals egg to
work: (use date-literals) wasn't able to find the module.

After some investigation, Peter pointed out that no import library was
being installed.

Here's a patch that builds and installs the import as well as increases
the version number.

Regards,
 <at> ndy

--

-- 
andyjpb <at> ashurst.eu.org
http://www.ashurst.eu.org/
0290 DA75 E982 7D99 A51F  E46A 387A 7695 7EBA 75FF

_______________________________________________
Chicken-users mailing list
Chicken-users <at> nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users
F. Rafael Leon | 7 Apr 17:21 2015
Picon

Chicken Workflow for Editing C Code

On Tue, Apr 7, 2015 at 9:48 AM, Peter Bex <peter <at> more-magic.net> wrote:
>> Even when editing the C code, I wrap it in chicken and dynamically
>> load it over and over again as I refine the inner loop.
>
> Hey, that sounds interesting!  How do you do that?

This is a whole different topic from the performance debate.

I do the following and "It Works For Me":

I work from a chicken REPL.  I run the chicken interpreter with the
linenoise egg:

 http://wiki.call-cc.org/eggref/4/linenoise

An alternative is to use rlwrap, but the result is that I end up with
a csi prompt with readline support:

#;1>

In theory, it would be even better to run csi in an emacs buffer, but
I never adapted to that habit.

From the prompt, I load a set of data into memory, and I put it in
srfi-4 vectors in the interpreter:

(define big-vector-a ... )
(define big-vector-b ... )

That is my starting state: a scheme prompt which represents a window
into a context holding some utility functions and lots of packed
binary data.

There are three more pieces to the puzzle:

Makefile - compiles and links things
innerloop.c - the file with the inner loop function with a "for" loop inside
example.scm - the wrapper for example.c

*** Makefile looks something like:

libexample.so: example.o
        ld -shared -o example.so example.o $(LIBDIR) -lchicken

%.o: %.c
        gcc -c -fPIC $^ $(INCDIR)

example.c: innerloop.c
        chicken example.scm

*** innerloop.c looks like:

int innerfunc(unsigned char *dat){
              for( ... ){
                        ... }
                  }

*** and example.scm:

(declare (unit example))

(foreign-declare "#include \"innerloop.c\" ")
(define innerwrap
    (lambda (mybigvector)
           ((foreign-lambda
             int
             innerfunc u8vector)
             mybigvector)))

*************************

and then from my prompt, I run:

#;1> (load-library 'example "libexample.so")
#;2> (innerwrap big-vector-a)

Then, edit innerloop.c and type "make" again and then hit the up arrow
and the enter key:

#;3> (load-library 'example "libexample.so")
#;4> (innerwrap big-vector-a)

I do this over and over again until the C code is fast.

   -Rafael
F. Rafael Leon | 7 Apr 15:33 2015
Picon

Re: Chicken-users Digest, Vol 149, Issue 2

On Tue, Apr 7, 2015 at 7:00 AM,  <chicken-users-request <at> nongnu.org> wrote:
> But I'm sick and tired of people throwing badly written code into the
> net and making gross assumptions about implementation performance. The
> possible options, the search-space available is massive and a little
> difference in programming style can make a vast difference in
> performance.

This is even true when benchmarking code fragments written in
different styles and run on the same implementation.

The performance variation is so severe that I write my inner loops for
numerics in C.

For an n-dimensional array, the infamous "innermost loop" is 1-dimensional.
The C code condenses down to a single "for" loop of maybe 10 lines in length.

The speed problem has thus been easily converted into a Scheme-to-C
interfacing problem.
Using chicken, I find that interfacing Scheme and C is not really much
of a problem at all.

The rest of the program is then written in chicken scheme in an
arbitrary style with no consideration of performance.
The emphasis for the scheme code is readability/maintainability etc.

Incidentally, this approach works perfectly on Android using the NDK
and some custom make files.
Even when editing the C code, I wrap it in chicken and dynamically
load it over and over again as I refine the inner loop.

No implementation is as fast as 10 lines of hand-optimized C.

After using this technique, I feel that the debate over implementation
performance seems rather silly, especially when discussing actual
numerical algorithms.  For recursion over arbitrary data structures,
another optimization approach might be needed.

In the old days, people would write inner loops in assembly.

     -Rafael
Kooda | 29 Mar 00:50 2015

rest-bind request headers support

Hi,

I’m trying to use rest-bind for a project and need to be able to add
some headers to the http requests, which rest-bind didn’t permit, even
when passing a request object.

Here is a simple patch that fixes this issue:

--- rest-bind.scm.orig	2015-03-29 00:26:49.000000000 +0100
+++ rest-bind.scm	2015-03-29 00:24:43.000000000 +0100
 <at>  <at>  -94,7 +94,9  <at>  <at> 
 				       (else (uri-reference uri/req))))
 			(method  (cond ((request? uri/req) (request-method uri/req))
 				       (writer 'POST)
-				       (else 'GET))))
+				       (else 'GET)))
+			(headers (cond ((request? uri/req) (request-headers uri/req))
+				       (else (headers '())))))
 		   (lambda ,proc-args
 		     (let* (, <at> (if (not (null? uri-args))
 			      `((uri (update-uri uri path: (append (uri-path uri) (map ->string (list , <at> uri-args)))))
 <at>  <at>  -109,7 +111,7  <at>  <at> 
 												     ,param)))
 										  params))))))
 				   '())
-			   (req (make-request uri: uri method: method)) ; poke the args into query string.
+			   (req (make-request uri: uri method: method headers: headers)) ; poke the args into query string.
 			   )
 		       (receive (reader uri response)
 				(call-with-input-request req ,(if writer '(writer body) #f) ,reader)

--

-- 
Envoyé depuis ma GameBoy.

_______________________________________________
Chicken-users mailing list
Chicken-users <at> nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users
Andy Bennett | 27 Mar 13:37 2015

Fwd: Re: headers with nginx + awful

Is this thing on?
I seem to be having trouble posting this.

-------- Forwarded Message --------
Subject: Re: [Chicken-users] headers with nginx + awful
Date: Tue, 24 Mar 2015 22:13:11 +0000
From: Andy Bennett <andyjpb <at> ashurst.eu.org>
To: Nathaniel Rudavsky-Brody <nathaniel <at> studio.cm>

Hi,

Given that it's happening with Firefox but not with Curl, I'd look into
the connection reuse between nginx and spiffy.

Curl always opens a new http connection: Firefox might reuse one that it
has around already.

Does this happen only on not-the-first-request?

Sorry to top post.

> I'm having a problem with headers when using nginx's proxy_pass with
> awful, and I'm not sure if it's a question of nginx or Chicken, or just
> my misunderstanding of headers...
> 
> Everything works fine except when I use (send-static-file) as in:
> 
> (define-page (regexp "/file/.+")
>   (lambda (url)
>       (parameterize ((root-path (data-dir)))
>           (send-static-file (string-drop url 6)))))
> 
> In this case, Firefox shows me a set of Spiffy headers at the end of the
> response body, even though they should be replaced by nginx's headers,
> which seem to be fine:
> 
> <html>
>   ...
> </html>
> HTTP/1.1 200 OK
> Content-Type: text/html
> Server: Spiffy/5.3 (Running on Chicken 4.8.0.6)
> Content-Length: 6
> Date: Tue, 24 Mar 2015 16:01:46 GMT
> 
> 483702
> 
> Curl, however, only sees the nginx headers, with nothing extra at the end:
> 
> HTTP/1.1 200 OK
> Server: nginx/1.4.6 (Ubuntu)
> Date: Tue, 24 Mar 2015 16:24:42 GMT
> Content-Type: text/html
> Content-Length: 483704
> Connection: keep-alive
> Last-Modified: Tue, 24 Mar 2015 16:23:40 GMT
> Etag: "483704-1427214220.0"
> 
> <html>
>   ...
> </html>
> 
> My nginx config is just:
> 
>     server {
>           listen        7000;
>           location / {
>                    proxy_pass http://localhost:8080;
> 
>           }
>         }
> 
> Many thanks for any ideas.
> 
> Nathaniel
> 
> 
> 
> 
> 
> _______________________________________________
> Chicken-users mailing list
> Chicken-users <at> nongnu.org
> https://lists.nongnu.org/mailman/listinfo/chicken-users
> 

Regards,
 <at> ndy

-- 
andyjpb <at> ashurst.eu.org
http://www.ashurst.eu.org/
0290 DA75 E982 7D99 A51F  E46A 387A 7695 7EBA 75FF

Regards,
 <at> ndy

--

-- 
andyjpb <at> ashurst.eu.org
http://www.ashurst.eu.org/
0290 DA75 E982 7D99 A51F  E46A 387A 7695 7EBA 75FF
Matt Gushee | 27 Mar 03:53 2015
Picon

Basic abnf usage?

Hello--

I'm attempting to learn how to use the abnf egg, but I'm having some difficulties.

First of all, I think the example needs to be updated. It uses the 'lit' matcher, which requires 'abnf-charlist' to be imported; also, the 'fws' and 'cfws' symbols are not defined. It's not hard to define them if you know the grammar, but given that this is the only example for the egg, it would be nice if it were a complete working example.

However, the greater challenge for me is understanding how to use the parsing rules once you have defined them. Since there is apparently no 'parse' function, I have no idea what to do. Is it necessary to define one's own parser? If so, what arguments does it need to take, and what does it return?

Thanks for any info.

--
Matt Gushee
_______________________________________________
Chicken-users mailing list
Chicken-users <at> nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users
Andy Bennett | 26 Mar 15:12 2015

Fwd: Re: headers with nginx + awful


-------- Forwarded Message --------
Subject: Re: [Chicken-users] headers with nginx + awful
Date: Tue, 24 Mar 2015 22:13:11 +0000
From: Andy Bennett <andyjpb <at> ashurst.eu.org>
To: Nathaniel Rudavsky-Brody <nathaniel <at> studio.cm>

Hi,

Given that it's happening with Firefox but not with Curl, I'd look into
the connection reuse between nginx and spiffy.

Curl always opens a new http connection: Firefox might reuse one that it
has around already.

Does this happen only on not-the-first-request?

Sorry to top post.

> I'm having a problem with headers when using nginx's proxy_pass with
> awful, and I'm not sure if it's a question of nginx or Chicken, or just
> my misunderstanding of headers...
> 
> Everything works fine except when I use (send-static-file) as in:
> 
> (define-page (regexp "/file/.+")
>   (lambda (url)
>       (parameterize ((root-path (data-dir)))
>           (send-static-file (string-drop url 6)))))
> 
> In this case, Firefox shows me a set of Spiffy headers at the end of the
> response body, even though they should be replaced by nginx's headers,
> which seem to be fine:
> 
> <html>
>   ...
> </html>
> HTTP/1.1 200 OK
> Content-Type: text/html
> Server: Spiffy/5.3 (Running on Chicken 4.8.0.6)
> Content-Length: 6
> Date: Tue, 24 Mar 2015 16:01:46 GMT
> 
> 483702
> 
> Curl, however, only sees the nginx headers, with nothing extra at the end:
> 
> HTTP/1.1 200 OK
> Server: nginx/1.4.6 (Ubuntu)
> Date: Tue, 24 Mar 2015 16:24:42 GMT
> Content-Type: text/html
> Content-Length: 483704
> Connection: keep-alive
> Last-Modified: Tue, 24 Mar 2015 16:23:40 GMT
> Etag: "483704-1427214220.0"
> 
> <html>
>   ...
> </html>
> 
> My nginx config is just:
> 
>     server {
>           listen        7000;
>           location / {
>                    proxy_pass http://localhost:8080;
> 
>           }
>         }
> 
> Many thanks for any ideas.
> 
> Nathaniel
> 
> 
> 
> 
> 
> _______________________________________________
> Chicken-users mailing list
> Chicken-users <at> nongnu.org
> https://lists.nongnu.org/mailman/listinfo/chicken-users
> 

Regards,
 <at> ndy

-- 
andyjpb <at> ashurst.eu.org
http://www.ashurst.eu.org/
0290 DA75 E982 7D99 A51F  E46A 387A 7695 7EBA 75FF

Regards,
 <at> ndy

--

-- 
andyjpb <at> ashurst.eu.org
http://www.ashurst.eu.org/
0290 DA75 E982 7D99 A51F  E46A 387A 7695 7EBA 75FF

Gmane