Re: [Chicken-users] irregex-replace return value

2014-03-04 Thread Michele La Monaca
On Tue, Mar 4, 2014 at 1:05 AM, Michele La Monaca
mikele.chic...@lamonaca.net wrote:
 (define (my-own-irregex-replace irx s . o)
   (let ((m (irregex-search irx s)))
 (and m (string-append
  (substring s 0 (irregex-match-start-index m 0))
  (apply string-append (reverse (irregex-apply-match m o)))
  (substring s (irregex-match-end-index m 0) (string-length
 s))

 After some pondering I realized that it would be valuable to provide
 this primitive in the library:

 (define (irregex-replace-match m str o)
   (string-append
 (substring str 0 (irregex-match-start-index m 0))
 (apply string-append (reverse (irregex-apply-match m o)))
 (substring str (irregex-match-end-index m 0) (string-length str

After some more mulling, I concluded that it would be even more
convenient to have a generalised version of irregex-replace-match
which also accepts lists of matches:

(irregex-replace-match match-or-list-of-matches str o)

On top of that, it would be easy to build irregex-replace/all semantics, too:

(define (irregex-replace/all irx str . o)
  (let ((ms (irregex-search/all irx str)))
(if (pair? ms) (irregex-replace-match ms str o) str)))

(define (my-irregex-replace irx str . o)
  (let ((ms (irregex-search/all irx str)))
(and (pair? ms) (irregex-replace-match ms str o

It would also be possible to easily implement less common actions like that:

(define (irregex-replace/2nd-and-4th irx str . o)
  (let ((ms (irregex-search/all irx str 4)))
(if (pair? ms)
  (irregex-replace-match (list (list-ref ms 1) (list-ref ms 3)) str o)
  str)))

Michele

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] Why is it called Chicken?

2014-03-04 Thread Daniel Carrera
Perhaps a silly question, but I'm curious. Why is Chicken Scheme called
Chicken?

Cheers,
Daniel.
-- 
When an engineer says that something can't be done, it's a code phrase that
means it's not fun to do.
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Why is it called Chicken?

2014-03-04 Thread Kristian Lein-Mathisen
Hi Daniel,

There's an interview with
Felixhttp://spin.atomicobject.com/2013/05/02/chicken-scheme-part-1/that
might answer your question:

*One last question: What inspired the names CHICKEN and SPOCK? Do they mean
 anything, aside from the bird and the well-known Star Trek character?*

 That question always comes up, sooner or later. ;-)

 I had a plastic toy of Feathers McGraw on my desk, the evil penguin
 (disguised as a chicken!) from the Wallace and Gromit movie, “The Wrong
 Trousers.” Looking for a preliminary working title for the compiler, I used
 the first thing that came to my mind that day. I’m somewhat superstitious
 about names for software projects, and things were progressing well, so I
 didn’t dare to change the name.


K.



On Tue, Mar 4, 2014 at 3:22 PM, Daniel Carrera dcarr...@gmail.com wrote:

 Perhaps a silly question, but I'm curious. Why is Chicken Scheme called
 Chicken?

 Cheers,
 Daniel.
 --
 When an engineer says that something can't be done, it's a code phrase
 that means it's not fun to do.

 ___
 Chicken-users mailing list
 Chicken-users@nongnu.org
 https://lists.nongnu.org/mailman/listinfo/chicken-users


___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Why is it called Chicken?

2014-03-04 Thread Daniel Carrera
Heh. That's great. And thanks for the link.

Cheers,
Daniel.


On 4 March 2014 15:42, Kristian Lein-Mathisen kristianl...@gmail.comwrote:


 Hi Daniel,

 There's an interview with 
 Felixhttp://spin.atomicobject.com/2013/05/02/chicken-scheme-part-1/that 
 might answer your question:

 *One last question: What inspired the names CHICKEN and SPOCK? Do they
 mean anything, aside from the bird and the well-known Star Trek character?*

 That question always comes up, sooner or later. ;-)

 I had a plastic toy of Feathers McGraw on my desk, the evil penguin
 (disguised as a chicken!) from the Wallace and Gromit movie, “The Wrong
 Trousers.” Looking for a preliminary working title for the compiler, I used
 the first thing that came to my mind that day. I’m somewhat superstitious
 about names for software projects, and things were progressing well, so I
 didn’t dare to change the name.


 K.



 On Tue, Mar 4, 2014 at 3:22 PM, Daniel Carrera dcarr...@gmail.com wrote:

 Perhaps a silly question, but I'm curious. Why is Chicken Scheme called
 Chicken?

 Cheers,
 Daniel.
 --
 When an engineer says that something can't be done, it's a code phrase
 that means it's not fun to do.

 ___
 Chicken-users mailing list
 Chicken-users@nongnu.org
 https://lists.nongnu.org/mailman/listinfo/chicken-users





-- 
When an engineer says that something can't be done, it's a code phrase that
means it's not fun to do.
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Matchable not working in module

2014-03-04 Thread Matt Gushee
PS: I am aware of the uri-match egg, and considered using it, but I
felt the tree syntax was unnecessarily complex for this application.
If I can't get matchable working I might reconsider that choice.

On Tue, Mar 4, 2014 at 8:39 PM, Matt Gushee m...@gushee.net wrote:
 Hi, all--

 I'm working on a new version of my coq-au-vin egg; one of the major
 changes is that I am moving the FastCGI request handling code into a
 module within the egg--it was previously separate.

 However, I'm now getting a compile error like this:

 :  Warning: reference to possibly unbound identifier `ofs' in:
 :  Warning:failure527

 :  Error: module unresolved: cav-web-fcgi

 I am using 'match' from the matchable egg to dispatch requests, like this:

 : (match spec
 :   [(or ((/ ) GET #f) ((/ articles) GET #f))
 :   (send-html (get-article-list-page/html out: #f))]
 :   [(or ((/ ) GET #f) ((/ articles) GET ofs))
 :   (send-html (get-article-list-page/html out: #f offset:
 (string-number ofs)))]

 ... and so on. So 'ofs' is a variable in the pattern match.

 This code has been working for some time, but it was not in a module
 before; it still compiles if I comment out the module-specific code,
 i.e.:

 :  ; (module cav-web-fcgi
 ; *
 ; (import scheme chicken)

 but I cannot get it to compile as a module. I imagine it has something
 to do with 'match' being a macro, but I don't know what to do about
 it. Any ideas?

 --
 Matt Gushee

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Matchable not working in module

2014-03-04 Thread Evan Hanson
On 05/03/14 16:39, Matt Gushee wrote:
 However, I'm now getting a compile error like this:

 :  Warning: reference to possibly unbound identifier `ofs' in:
 :  Warning:failure527

 :  Error: module unresolved: cav-web-fcgi

 I am using 'match' from the matchable egg to dispatch requests, like this:

 : (match spec
 :   [(or ((/ ) GET #f) ((/ articles) GET #f))
 :   (send-html (get-article-list-page/html out: #f))]
 :   [(or ((/ ) GET #f) ((/ articles) GET ofs))
 :   (send-html (get-article-list-page/html out: #f offset:
 (string-number ofs)))]

 ... and so on. So 'ofs' is a variable in the pattern match.

`ofs` is only present in the second arm of the `(or ...)` pattern, so
I'm guessing this is due `ofs` being unbound in the expansion of the
first alternative. It's as if you had said:

(match a
  ((or #f x) x))

... Which will hopefully signal a similar error (hopefully --
untested!). This probably only worked before due to the forgiving nature
of the top level (which is hopeless, and so on). Anyway, try refactoring
the `match` clause to bind `ofs` in all cases and see if that helps.

Cheers,

Evan

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Matchable not working in module

2014-03-04 Thread Matt Gushee
Hi, Evan--

On Tue, Mar 4, 2014 at 10:36 PM, Evan Hanson ev...@foldling.org wrote:

 :   [(or ((/ ) GET #f) ((/ articles) GET ofs))
 :   (send-html (get-article-list-page/html out: #f offset:
 (string-number ofs)))]

 `ofs` is only present in the second arm of the `(or ...)` pattern, so
 I'm guessing this is due `ofs` being unbound in the expansion of the
 first alternative. It's as if you had said:

Whoops! You're right. I'm surprised I didn't catch that before. Looks
like that #f in the first branch should have been 'ofs' all along.

 untested!). This probably only worked before due to the forgiving nature
 of the top level (which is hopeless, and so on).

If by top level you mean the REPL, that's not the issue. That code
compiled (many times) and has been running on my web server for 4
months. Only when I wrapped it in a module did it fail to compile.
Isn't that a little disturbing?

If I had some sort of rigorous test script, I probably would have
caught that error; I really don't know how to do that for a FastCGI
app. Since it won't really work without the (separate) web server,
normal unit testing isn't very applicable.

Anyway, many thanks for spotting that. Now I will be able to sleep tonight ;-)

--
Matt Gushee

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users