Re: [Chicken-users] two-dimensional syntax-rules

2017-03-10 Thread Sascha Ziemann
2017-03-10 10:55 GMT+01:00 Peter Bex :
>
> Gauche and Racket accept this macro application, Scheme48 rejects it (but
> that's expected, because our syntax-rules is originally from Scheme48).
>

But Gauche fails like Chibi. They silently ignore the last ellipsis.

$ chibi-scheme
> (define-syntax define-facts
  (syntax-rules ()
((_ (name a0 a1 ...) ((v00 v01 ...) (v10 v11 ...) ...))
 '(define (name a0 a1 ...)
(conde
  ((== a0 v00) (== a1 v01) ...)
  ((== a0 v10) (== a1 v11) ...)
  ...)
> (define-facts (fathero f c)
  (("Abraham" "Ismael")
   ("Abraham" "Isaac")
   ("Isaac"   "Jacob")
   ("Jacob"   "Benjamin")))
(define (fathero f c) (conde ((== f "Abraham") (== c "Ismael")) ((== f
"Abraham") (== c "Isaac"

MIT and Ikarus succeed like Guile.

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


[Chicken-users] two-dimensional syntax-rules

2017-03-10 Thread Sascha Ziemann
I have the following macro:

(define-syntax define-facts
  (syntax-rules ()
((_ (name a0 a1 ...) ((v00 v01 ...) (v10 v11 ...) ...))
 '(define (name a0 a1 ...)
(conde
  ((== a0 v00) (== a1 v01) ...)
  ((== a0 v10) (== a1 v11) ...)
  ...)

In Guild 2.0.9 it works as expected:

scheme@(guile-user)> (define-facts (fathero f c)
  (("Abraham" "Ismael")
   ("Abraham" "Isaac")
   ("Isaac"   "Jacob")
   ("Jacob"   "Benjamin")))
$1 = (define (fathero f c) (conde ((== f "Abraham") (== c "Ismael"))
((== f "Abraham") (== c "Isaac")) ((== f "Isaac") (== c "Jacob")) ((==
f "Jacob") (== c "Benjamin"

But in Chicken csi get the following error:

CHICKEN
(c) 2008-2013, The Chicken Team
(c) 2000-2007, Felix L. Winkelmann
Version 4.8.0.5 (stability/4.8.0) (rev 5bd53ac)
linux-unix-gnu-x86-64 [ 64bit manyargs dload ptables ]
compiled 2013-10-03 on aeryn.xorinia.dim (Darwin)

#;1> (define-syntax define-facts
  (syntax-rules ()
((_ (name a0 a1 ...) ((v00 v01 ...) (v10 v11 ...) ...))
 '(define (name a0 a1 ...)
(conde
  ((== a0 v00) (== a1 v01) ...)
  ((== a0 v10) (== a1 v11) ...)
  ...)
#;2> (define-facts (fathero f c)
  (("Abraham" "Ismael")
   ("Abraham" "Isaac")
   ("Isaac"   "Jacob")
   ("Jacob"   "Benjamin")))

Error: (map) during expansion of (define-facts ...) - lists are not of
same length: (() (("Jacob") ("Benjamin")))

Call history:

(##sys#map-n (lambda8 (a1 v01) (##sys#cons (rename14
(##core#syntax ==)) (##sys#cons a1 (##sys#cons v01...
(##sys#cons (rename14 (##core#syntax ==))
(##sys#cons a1 (##sys#cons v01 (quote13 ()
(rename14 (##core#syntax ==))
(##sys#cons a1 (##sys#cons v01 (quote13 (
(##sys#cons v01 (quote13 ()))
(##sys#map-n (lambda8 (v10 a1 v11) (##sys#cons
(##sys#cons (rename14 (##core#syntax ==)) (##sys#cons..
(##sys#cons (##sys#cons (rename14 (##core#syntax
==)) (##sys#cons a0 (##sys#cons v10 (quote13 ()...
(##sys#cons (rename14 (##core#syntax ==))
(##sys#cons a0 (##sys#cons v10 (quote13 ()
(rename14 (##core#syntax ==))
(##sys#cons a0 (##sys#cons v10 (quote13 (
(##sys#cons v10 (quote13 ()))
(##sys#map-n (lambda8 (v11) (##sys#cons (rename14
(##core#syntax ==)) (##sys#cons a1 (##sys#cons v11...
(##sys#cons (rename14 (##core#syntax ==))
(##sys#cons a1 (##sys#cons v11 (quote13 ()
(rename14 (##core#syntax ==))
(##sys#cons a1 (##sys#cons v11 (quote13 (
(##sys#cons v11 (quote13 ())) <--

I am not sure if it is a bug, because Chibi and Gambit fail, too. But
Petite Chez does it like Guile.

Is it a bug?

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


[Chicken-users] Fwd: Chicken on Solaris

2015-03-15 Thread Sascha Ziemann
Hello,

the solution setting INSTALL_PROGRAM works fine for me.

Regards,
Sascha


-- Forwarded message --
From: Michele La Monaca mikele.chic...@lamonaca.net
Date: 2015-03-13 21:18 GMT+01:00
Subject: Re: [Chicken-users] Chicken on Solaris
To: Sascha Ziemann cev...@gmail.com


Hi Sascha,

glad to know it helped.

Can you send your reply also to the mailing list in order to share
your (positive) experience with this workaround?

Thanks,
Michele

On Fri, Mar 13, 2015 at 2:24 PM, Sascha Ziemann cev...@gmail.com wrote:
 2015-03-12 17:33 GMT+01:00 Michele La Monaca mikele.chic...@lamonaca.net:
 make PLATFORM=solaris INSTALL_PROGRAM=/usr/ucb/install install


 Thanks! This helps. Although I had to use gmake.

 Regards,
 Sascha

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


[Chicken-users] Chicken on Solaris

2015-03-12 Thread Sascha Ziemann
I tried to install Chicken on Solaris. Compilation works fine but
installation fails:

$ gmake PLATFORM=solaris PREFIX=$HOME/chicken install
gmake -f ./Makefile.solaris CONFIG= install
gmake[1]: Entering directory `/export/home/x/chicken-4.9.0.1'
install -d -m 755 /export/home/x/chicken/lib
directory /export/home/x/chicken/lib created
ginstall -m 755 libchicken.so /export/home/x/chicken/lib/libchicken.so.7
/bin/sh: ginstall: not found
gmake[1]: *** [install-libs] Error 1
gmake[1]: Leaving directory `/export/home/x/chicken-4.9.0.1'
gmake: *** [install] Error 2

It seems to me that configure has missed to check for ginstall.

$ type ginstall
-bash: type: ginstall: not found

I tried Solaris 10:

$ uname -a
SunOS  5.10 Generic_150400-04 sun4v sparc SUNW,SPARC-Enterprise-T5120

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


[Chicken-users] Why are 32 bit inexact?

2014-12-28 Thread Sascha Ziemann
Hi,

I tried to play a bit with ARM assembler, but reading 4 byte from a port
seems to be quite hard with Chicken.

Why are 32 bits inexact?

(exact? #b1000) - #f

What is the easiest way to read a 32 bit word in a looseless way from a
port?

Regards,
Sascha

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


[Chicken-users] How to tell csc to call main?

2014-12-19 Thread Sascha Ziemann
Hi,

How to tell csc to call main in the same way like csi -ss?

$ cat distribution.scm
#! /usr/bin/csi -ss

(define (main args)
(display main\n))
$ ./distribution.scm
main
$ csc distribution.scm
$ ./distribution
$

csc does not seem to have a -ss option.

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


Re: [Chicken-users] sxpath does not preserve node order

2014-12-05 Thread Sascha Ziemann
At Fri, 05 Dec 2014 11:55:39 +0100,
Jörg F. Wittenberger wrote:
 
 Am 04.12.2014 um 21:25 schrieb Sascha Ziemann:
  It seems to me that the use of //* duplicates the inner 'a' node:
 
 That's not what it does.  I'm not completely sure that XPath does
 require this behavior, but I tend to believe this is the right thing to
 do.  // is supposed to yield all descendant nodes, in this example the
 second span (sure including this span's descendant a) and the a
 node itself.

Ok this could be true.  Saxon seems to do it in this way.

echo 'spana//span' | java -cp saxon9he.jar net.sf.saxon.Query 
'!omit-xml-declaration=1' -s:- -qs:'//*' ; echo
spana//spana/

Regards,
Sascha

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


[Chicken-users] sxpath does not preserve node order

2014-12-04 Thread Sascha Ziemann
Hi,

I have a problem with Sxpath not preserving the node order.

This example:

  (use regex)
  (use http-client)
  (use sxpath)
  (use html-parser)
  ((sxpath //h1[@class='header']//*/text())
   (with-input-from-request
http://www.imdb.com/title/tt0497465/;
#f html-sxml))

returns

  (Vicky Cristina Barcelona ( ) 2008)

But the correct node order would be

  (Vicky Cristina Barcelona ( 2008 ))

If I try the same in Firebug the order is correct:

  $x(//h1[@class='header']//*/text())
  [TextNode textContent=Vicky Cristina Barcelona,
   TextNode textContent=(,
   TextNode textContent=2008,
   TextNode textContent=)]

Is this a bug? Or is the node order unspecified?

Regards,
Sascha

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


Re: [Chicken-users] sxpath does not preserve node order

2014-12-04 Thread Sascha Ziemann
It seems to me that the use of //* duplicates the inner 'a' node:

(begin
  (newline)
  (pp ((sxpath //h1[@class='header']//*)
 (with-input-from-request
  http://www.imdb.com/title/tt0497465/;
  #f html-sxml

prints

((span (@ (class itemprop) (itemprop name)) Vicky Cristina Barcelona)
 (span (@ (class nobr))
   (
   (a (@ (href /year/2008/?ref_=tt_ov_inf)) 2008)
   ))
 (a (@ (href /year/2008/?ref_=tt_ov_inf)) 2008))

Although there is only one hyper-ref in the HTML code.


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


[Chicken-users] UTF-8 to UTF-16 on Windows

2014-12-04 Thread Sascha Ziemann
Hi,

what is the easiest way, when using Chicken on Windows, to convert a
UTF-8 string to UTF-16?

It seems to me that rename-file needs UTF-16 encoded strings on Windows.

Regards,
Sascha

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


[Chicken-users] file-separator, path-separator

2014-10-26 Thread Sascha Ziemann
Hi,

what is the Chicken equivalent of Java's File.separator

  http://docs.oracle.com/javase/8/docs/api/java/io/File.html#separator

and File.pathSeparator:

  http://docs.oracle.com/javase/8/docs/api/java/io/File.html#pathSeparator

Something like this maybe:

(use posix)

(define file-separator #f)
(define path-separator #f)

(let ((sysname (let ((si (system-information)))
 (if (pair? si)
 (car si)
 #f
  (cond
   ((equal? sysname windows)
(set! file-separator \\)
(set! path-separator ;))
   (else
(set! file-separator /)
(set! path-separator :

Is it already defined anywhere? I could not find it.

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


[Chicken-users] Use Chicken 3 egg in 4

2014-10-09 Thread Sascha Ziemann

Hi,

is it possible to use a Chicken 3 egg like the the SMTP client in 
Chicken 4? I can not find the SMTP client in the version 4 eggs.


Regards,
Sascha

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


[Chicken-users] Non printable characters in call history

2014-10-07 Thread Sascha Ziemann
Hi,

Chicken prints non printable characters in its call history:

syntax  (string-blob405 �x\x1e�`�ռ�UF���~F)

My terminal crashed just because of this.

Is it the intended behavior? Or can I change this by myself?

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


[Chicken-users] How to compile with openssl?

2014-10-07 Thread Sascha Ziemann
Hi,

I have a small program talking XML-RPC over HTTPS. When I run it with csi
it works fine:

$ csi -s domrobot.scm 127.0.0.1
Record updated.

But when I try the compiled version I get an error:

$ csc domrobot.scm
$ ./domrobot 127.0.0.1

Error: (ssl-connect) Unable to connect over HTTPS. To fix this, install the
openssl egg and try again: https://api.domrobot.com/xmlrpc/;

Call history:

http-client#ensure-local-connections
http-client#connections-owner
current-thread
http-client#connections
hash-table-ref/default
open-output-string
uri-common#uri-host
write
write-char/port
uri-common#uri-port
uri-generic#uri-port
uri-generic#uri-scheme
alist-ref
write
get-output-string
raise   --

This are the modules I use:

(use http-client
 uri-common
 uuid
 xml-rpc-client
 blowfish)

I tried to load all directly imported modules and also the indirectly
imported openssl module before compilation:

(begin-for-syntax
 (require-extension openssl)
 (require-extension http-client)
 (require-extension uri-common)
 (require-extension uuid)
 (require-extension xml-rpc-client)
 (require-extension blowfish))

But this does not help.

Can anybody give me a hint what else I have to do to compile the program?

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


Re: [Chicken-users] How to compile with openssl?

2014-10-07 Thread Sascha Ziemann
2014-10-07 13:45 GMT+02:00 Christian Kellermann ck...@pestilenz.org:

 * Sascha Ziemann cev...@gmail.com [141007 13:37]:
  The binary is not linked against Openssl:
 
  $ ldd domrobot
  linux-gate.so.1 =  (0xb7793000)
  libchicken.so.6 = /usr/lib/libchicken.so.6 (0xb7402000)
  libm.so.6 = /lib/i386-linux-gnu/libm.so.6 (0xb73d6000)
  libdl.so.2 = /lib/i386-linux-gnu/libdl.so.2 (0xb73d2000)
  libc.so.6 = /lib/i386-linux-gnu/libc.so.6 (0xb7284000)
  /lib/ld-linux.so.2 (0xb7794000)
 
  Should it be so?

 Yes, I think it should.


I tried it but it does not help either:

$ csc -L/usr/lib/i386-linux-gnu/i586 -lssl domrobot.scm
$ ldd domrobot
linux-gate.so.1 =  (0xb77ae000)
libssl.so.1.0.0 = /usr/lib/i386-linux-gnu/i586/libssl.so.1.0.0
(0xb774c000)
libchicken.so.6 = /usr/lib/libchicken.so.6 (0xb73bd000)
libm.so.6 = /lib/i386-linux-gnu/libm.so.6 (0xb7397000)
libdl.so.2 = /lib/i386-linux-gnu/libdl.so.2 (0xb7393000)
libc.so.6 = /lib/i386-linux-gnu/libc.so.6 (0xb7245000)
libcrypto.so.1.0.0 =
/usr/lib/i386-linux-gnu/i586/libcrypto.so.1.0.0 (0xb7081000)
libz.so.1 = /lib/i386-linux-gnu/libz.so.1 (0xb7068000)
/lib/ld-linux.so.2 (0xb77af000)
$ ./domrobot 127.0.0.1

Error: (ssl-connect) Unable to connect over HTTPS. To fix this, install the
openssl egg and try again: https://api.domrobot.com/xmlrpc/;
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] How to compile with openssl?

2014-10-07 Thread Sascha Ziemann
2014-10-07 13:48 GMT+02:00 Peter Bex peter@xs4all.nl:


 You'll need to ensure that openssl is available to the application.
 Like the error message says, all you need to do is ensure that it's
 installed and it'll work.  If you're using -deploy, make sure that you
 add the egg to your application bundle.  If you're using a custom egg
 repository, ensure that openssl is in there.


I run the interpreted and compiled version on the same system. How can the
egg not being there for the compiled version, if it is there for the
interpreted version?

I tried strace on the interpreted and the compiled version. The funny thing
is, that the compiled version opens libssl and after that reports the error
that openssl is not available.

$ strace ./domrobot 127.0.0.1 21|grep ssl
stat64(/var/lib//chicken/6/openssl.so, {st_mode=S_IFREG|0755,
st_size=251089, ...}) = 0
stat64(/var/lib//chicken/6/openssl, 0xbff9239c) = -1 ENOENT (No such file
or directory)
stat64(/var/lib//chicken/6/openssl.so, {st_mode=S_IFREG|0755,
st_size=251089, ...}) = 0
open(/var/lib//chicken/6/openssl.so, O_RDONLY) = 3
open(/usr/lib/i586/libssl.so.1.0.0, O_RDONLY) = -1 ENOENT (No such file
or directory)
open(/usr/lib/libssl.so.1.0.0, O_RDONLY) = -1 ENOENT (No such file or
directory)
open(/usr/lib/i586/libssl.so.1.0.0, O_RDONLY) = -1 ENOENT (No such file
or directory)
open(/usr/lib/libssl.so.1.0.0, O_RDONLY) = -1 ENOENT (No such file or
directory)
open(/usr/lib/i386-linux-gnu/i586/libssl.so.1.0.0, O_RDONLY) = 3
write(2, (ssl-connect) Unable to connect ..., 94(ssl-connect) Unable to
connect over HTTPS. To fix this, install the openssl egg and try again) = 94

csi opens just the same lib:

$ grep /usr/lib/i386-linux-gnu/i586/libssl.so.1.0.0 *.trace
csc.trace:open(/usr/lib/i386-linux-gnu/i586/libssl.so.1.0.0, O_RDONLY) = 3
csi.trace:open(/usr/lib/i386-linux-gnu/i586/libssl.so.1.0.0, O_RDONLY) = 4

I do not think that my system installation is broken. I think csi and csc
do different things with libssl.

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


Re: [Chicken-users] How to compile with openssl?

2014-10-07 Thread Sascha Ziemann
2014-10-07 14:28 GMT+02:00 Kristian Lein-Mathisen kristianl...@gmail.com:


 which CHICKEN version are you using?


It is the one which comes with Debian stable:  4.7.0-1


 There is a bug in some older versions where you need to specify (use
 chicken-syntax) for it work in compiled modules. Does that help?


Yes! This helps. Thanks!

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


Re: [Chicken-users] How to compile with openssl?

2014-10-07 Thread Sascha Ziemann
2014-10-07 15:23 GMT+02:00 Christian Kellermann ck...@pestilenz.org:

 If you can please consider upgrading, 4.7.0 is horribly out of date
 and tons of bugs have been fixed in the meantime.


With the two non obvious lines:

  (use chicken-syntax)
  (begin-for-syntax (require-extension blowfish))

it works better than Perl's XMLRPC::Lite which fails to parse the XML
result of a method I need and which needs also Jessi packages on Wheezy.
Installing Jessi packages on Wheezy puzzles Apt and causes package
dependency errors. With the Chicken version I can remove the Jessi packages
and Apt is happy again.

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


[Chicken-users] How to load modules for compilation

2014-10-06 Thread Sascha Ziemann
Hi,

I have a simple program using the blowfish egg in a macro to do some
obscurity:

(require-extension blowfish)

(define-syntax curtain
  (ir-macro-transformer
(lambda (form inject compare?)
  (let* ((str (cadr form))
 (len (string-length str))
 (pad (make-string (- 8 (modulo len 8)) #\space))
 (key (with-input-from-file /dev/urandom
(lambda ()
  (read-string 56
 (hidden (blob-string ((make-blowfish-encryptor (string-blob
key))
(string-blob (string-append str
pad))
`(lambda ()
   (substring (blob-string ((make-blowfish-decryptor (string-blob
,key))
 (string-blob ,hidden)))
  0 ,len))

(define (main . args)
  (display ((curtain top-secret)))
  (newline))

When I run it with csi it works fine:

$ csi -ss curtain.scm
top-secret

But when I try to compile it I get an error:

$ csc -R blowfish -ss curtain.scm

Error: during expansion of (curtain ...) - unbound variable:
blowfish#make-blowfish-encryptor

Call history:

syntax  (##core#lambda args (display ((curtain
top-secret))) (newline))
syntax  (##core#begin (display ((curtain top-secret)))
(newline))
syntax  (display ((curtain top-secret)))
syntax  ((curtain top-secret))
syntax  (##core#let ((g33 (curtain top-secret))) (g33))
syntax  (curtain top-secret)
eval(cadr form)
eval(string-length str)
eval(make-string (- 8 (modulo len 8)) #\space)
eval(- 8 (modulo len 8))
eval(modulo len 8)
eval(with-input-from-file /dev/urandom (lambda ()
(read-string 56)))
eval(read-string 56)
eval(blob-string ((make-blowfish-encryptor (string-blob
key)) (string-blob (string-append str pad
eval((make-blowfish-encryptor (string-blob key))
(string-blob (string-append str pad)))
eval(make-blowfish-encryptor (string-blob key))  --

Error: shell command terminated with non-zero exit status 17920:
/usr/bin/chicken curtain.scm -output-file curtain.c -dynamic -feature
chicken-compile-shared -feature chicken-compile-shared -require-extension
blowfish

I am wondering why the blowfish function is unbound although I have
specified the module. Can anybody give me a hint what I did wrong?

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


Re: [Chicken-users] How to load modules for compilation

2014-10-06 Thread Sascha Ziemann
2014-10-06 15:53 GMT+02:00 Peter Bex peter@xs4all.nl:

 On Mon, Oct 06, 2014 at 03:44:38PM +0200, Sascha Ziemann wrote:
  Error: during expansion of (curtain ...) - unbound variable:
  blowfish#make-blowfish-encryptor

 You can do (begin-for-syntax (require-extension blowfish)) to make


Thanks! This helps. I thought the -R option would do it. But it seems to be
for something else.

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


[Chicken-users] How to pass a list to amb?

2014-08-24 Thread Sascha Ziemann
I tried to pass a list to amb but I do not know how to use amb-thunks. I
tried this:

(require-extension amb)

(let ((names '(a b c)))
  (amb-collect
   (let ((name (amb-thunks (map (lambda (x) x) names)))
 (value (amb 'c 'b 'a)))
 (amb-assert (eq? name value))
 value)))

(let ((names '(a b c)))
  (amb-collect
   (let ((name (amb-thunks names))
 (value (amb 'c 'b 'a)))
 (amb-assert (eq? name value))
 value)))

But both failes with:

Process scheme exited abnormally with code 139

This looks like a bug to me.

I have tested with 4.7.0 on Debian (Intel 32).
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] Syslog openlog segfaults

2013-02-04 Thread Sascha Ziemann
I am running the following test on Red Hat Enterprise Linux Server
release 6.3 (Santiago):

$ uname -m
x86_64
$ getconf LONG_BIT
64
$ cat crash.scm
#! /usr/xxx/bin/csi -s

(use syslog)

(openlog #f opt/pid facility/local0)

$ csi crash.scm

CHICKEN
(c)2008-2011 The Chicken Team
(c)2000-2007 Felix L. Winkelmann
Version 4.7.0.6
linux-unix-gnu-x86-64 [ 64bit manyargs dload ptables ]
compiled 2013-01-29 on xxx (Linux)

; loading crash.scm ...
; loading /usr/xxx/lib/chicken/6/syslog.import.so ...
; loading /usr/xxx/lib/chicken/6/chicken.import.so ...
; loading /usr/xxx/lib/chicken/6/scheme.import.so ...
; loading /usr/xxx/lib/chicken/6/foreign.import.so ...
; loading /usr/xxx/lib/chicken/6/extras.import.so ...
; loading /usr/xxx/lib/chicken/6/syslog.so ...
Segmentation fault

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


[Chicken-users] srfi-18 documentation for thread-sleep!

2011-12-16 Thread Sascha Ziemann
The documentation for the thread-sleep! function in the srfi-18
documentation mentions a function called current-time. But that can
not be found:

http://wiki.call-cc.org/search?text=ident=current-time

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


[Chicken-users] git rm write-line?

2011-09-21 Thread Sascha Ziemann
What the hell does write-line do?

I used this script:

#! /usr/local/bin/csi -s

(define (write-line* line)
  (display line)
  (newline))

(if (not (null? (command-line-arguments)))
(set! write-line write-line*))

(let next-line ((line (read-line)))
  (if (not (eof-object? line))
  (begin
(write-line line)
(next-line (read-line)

The build in write-line:

$ dd if=/dev/zero bs=1M count=100 | od -xv | cat.scm  /dev/null
100+0 records in
100+0 records out
104857600 bytes (105 MB) copied, 18.7047 s, 5.6 MB/s

The self written version:

$ dd if=/dev/zero bs=1M count=100 | od -xv | cat.scm 1  /dev/null
100+0 records in
100+0 records out
104857600 bytes (105 MB) copied, 13.3583 s, 7.8 MB/s

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


Re: [Chicken-users] git rm write-line?

2011-09-21 Thread Sascha Ziemann
2011/9/21 Christian Kellermann ck...@pestilenz.org:
 On a second thought, here is what write-line does:

 (define write-line
  (lambda (str . port)
    (let ((p (if (##core#inline C_eqp port '())
                 ##sys#standard-output
                 (##sys#slot port 0) ) ) )
      (##sys#check-port p 'write-line)
      (##sys#check-string str 'write-line)
      (display str p)
      (newline p) ) ) )


Ah I see. write-line is only a quick hack. I thought it would do
something fast like fwrite.

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


Re: [Chicken-users] git rm write-line?

2011-09-21 Thread Sascha Ziemann
2011/9/21 Christian Kellermann ck...@pestilenz.org:

 I prefer improvement.

Btw this is what Bigloo does.

Interpreted:

$ dd if=/dev/zero bs=1M count=100 | od -xv | bigloo -i cat.scm  /dev/null
100+0 records in
100+0 records out
104857600 bytes (105 MB) copied, 10.6036 s, 9.9 MB/s

Compiled with -static-all-bigloo:

$ dd if=/dev/zero bs=1M count=100 | od -xv | ./a.out  /dev/null
100+0 records in
100+0 records out
104857600 bytes (105 MB) copied, 8.07031 s, 13.0 MB/s

This is almost perfect compared to cat:

$ dd if=/dev/zero bs=1M count=100 | od -xv | cat  /dev/null
100+0 records in
100+0 records out
104857600 bytes (105 MB) copied, 7.61719 s, 13.8 MB/s

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


[Chicken-users] find-files

2011-09-21 Thread Sascha Ziemann
The documentation for find-files says: By default, symbolic links are
not followed.

Try this:

$ ln -s this .
$ csi -R posix -e '(write (find-files .))'

$ csi -v

CHICKEN
(c)2008-2011 The Chicken Team
(c)2000-2007 Felix L. Winkelmann
Version 4.7.0
linux-unix-gnu-x86-64 [ 64bit manyargs dload ptables ]
compiled 2011-09-16 on sn-e0692 (Linux)

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


Re: [Chicken-users] find-files

2011-09-21 Thread Sascha Ziemann
2011/9/21 Christian Kellermann ck...@pestilenz.org:

 A workaround is to explicitly specify follow-symlinks: #f in your
 call to find-files. Does that help you for now?

Of course. To be precise: I don't need it at all, because my data does
not have any symlinks. I tried it only out of spite. ;-)

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


[Chicken-users] for-each and mismatching list lengths

2011-09-20 Thread Sascha Ziemann
This throws an error:

(for-each (lambda (a b)
(printf ~s ~s\n a b))
  (list 1 2 3 0)
  (list 4 5 6))

But this does not:

(for-each (lambda (a b)
(printf ~s ~s\n a b))
  (list 1 2 3)
  (list 4 5 6 0))

Is this a bug or feature?

Guile throws out-of-range for both.

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


[Chicken-users] Chicken vs Perl

2011-09-20 Thread Sascha Ziemann
I tried to use Chicken for a job I would use normally Perl for to find
out whether Chicken might be a useful alternative.

The job is: go through a web site mirror and report a unique list of
all domains from all hrefs.

This is the my Perl version:

#! /usr/bin/perl

use warnings;
use strict;
use File::Find;

my $dir = $ARGV[0] || '.';
my @files;
my %urls;

find ({wanted = sub { push @files, $_ if -f $_; },
   no_chdir = 1}, $dir);

foreach my $file (@files) {
open (HTML, $file) || die Can not open file '$file';
while (HTML) {
while (/href=(http:\/\/[^\/?]+)([\/?].*)/i) {
$urls{lc $1} = 1;
$_ = $2; } }
close (HTML); }

foreach my $url (sort keys %urls) {
print $url, \n; }

The Perl version takes for my test tree about two seconds:

real0m1.810s
user0m1.664s
sys 0m0.140s

And this is my Chicken version:

#! /usr/local/bin/csi -s

(require-extension posix regex srfi-69)

(define dir (let ((args (command-line-arguments)))
  (if (pair? args)
  (car args)
  .)))
(define files (find-files dir regular-file?))
(define urls (make-hash-table))
(define href (regexp href=\(http://[^\/?]+)([\/?].*) #t))

(for-each
 (lambda (filename)
   (with-input-from-file filename
 (lambda ()
   (let next-line ((line (read-line)))
 (if (not (eof-object? line))
 (let next-href ((found (string-search href line)))
   (if found
   (begin
 (hash-table-set! urls (string-downcase (cadr found)) #t)
 (next-href (string-search href (caddr found)
   (next-line (read-line
 files)

(for-each
 (lambda (arg)
   (printf ~a\n arg))
 (sort (hash-table-keys urls) string?))

And now hold on tight! It takes more than one minute for the same data:

real1m16.540s
user1m14.849s
sys 0m0.664s

And there is almost no significant performance boost by compiling it:

real0m1.810s
user0m1.664s
sys 0m0.140s

So the questions are:

- What is wrong with the Chicken code?
- How can I profile the code?
- Why is there no difference between csi and csc?

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


Re: [Chicken-users] Chicken vs Perl

2011-09-20 Thread Sascha Ziemann
2011/9/20 Peter Bex peter@xs4all.nl:

 The most important question is: which version of Chicken is this?
 There have been massive optimizations done to irregex (the regex
 engine used in Chicken) between 4.6.0 and 4.7.0

csi -version reports this:

Version 4.7.0
linux-unix-gnu-x86-64 [ 64bit manyargs dload ptables ]

I compiled it a few days ago on a 64 bit Debian Lenny.

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


Re: [Chicken-users] Chicken vs Perl

2011-09-20 Thread Sascha Ziemann
2011/9/20 Alan Post alanp...@sunflowerriver.org:

 It looks like you have a copy-and-paste error here?

Yes it looks like. But this should be past error bullet proof:

$ for EXT in .pl .scm  ; do file ../../bin/grep-domains$EXT ; time
../../bin/grep-domains$EXT | md5sum ; done
../../bin/grep-domains.pl: a /usr/bin/perl script text executable
03dce8cb0dc986f0188df99c0bb23f24  -

real0m1.835s
user0m1.628s
sys 0m0.156s
../../bin/grep-domains.scm: a /usr/local/bin/csi -s script text executable
03dce8cb0dc986f0188df99c0bb23f24  -

real1m34.311s
user1m30.014s
sys 0m0.768s
../../bin/grep-domains: ELF 64-bit LSB executable, x86-64, version 1
(SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.8,
not stripped
03dce8cb0dc986f0188df99c0bb23f24  -

real1m0.481s
user0m58.332s
sys 0m0.600s

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


Re: [Chicken-users] Chicken vs Perl

2011-09-20 Thread Sascha Ziemann
2011/9/20 Christian Kellermann ck...@pestilenz.org:

 You can add -profile to csc's options. If you need any eggs and
 want those profiled too, recompile them also with -profile.

How to do that?

I have installed them with chicken-install. As far as I can see there
are no options to specify compilation options.

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


Re: [Chicken-users] Chicken vs Perl

2011-09-20 Thread Sascha Ziemann
2011/9/20 Daishi Kato dai...@axlight.com:

 My guess is that read-line is slower than  in perl.
 (I think  is so optimized in perl.)

Yes this is one reason.  I tried this:

$ dd if=/dev/zero bs=1M count=100 | od -xv | cat  /dev/null
100+0 records in
100+0 records out
104857600 bytes (105 MB) copied, 7.69538 s, 13.6 MB/s

$ dd if=/dev/zero bs=1M count=100 | od -xv | perl -pe 'print $_;'  /dev/null
100+0 records in
100+0 records out
104857600 bytes (105 MB) copied, 8.1591 s, 12.9 MB/s

$ dd if=/dev/zero bs=1M count=100 | od -xv | cat.scm  /dev/null
100+0 records in
100+0 records out
104857600 bytes (105 MB) copied, 36.9156 s, 2.8 MB/s

With cat.scm being this:

#! /usr/local/bin/csi -s

(let next-line ((line (read-line)))
  (if (not (eof-object? line))
  (begin
(printf ~a\n line)
(next-line (read-line)

But it is only about 5 times slower and not 30 times like my original program.

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


Re: [Chicken-users] Chicken vs Perl

2011-09-20 Thread Sascha Ziemann
2011/9/20 Sascha Ziemann cev...@gmail.com:

 $ dd if=/dev/zero bs=1M count=100 | od -xv | cat.scm  /dev/null
 100+0 records in
 100+0 records out
 104857600 bytes (105 MB) copied, 36.9156 s, 2.8 MB/s

 With cat.scm being this:

 #! /usr/local/bin/csi -s

 (let next-line ((line (read-line)))
  (if (not (eof-object? line))
      (begin
        (printf ~a\n line)
        (next-line (read-line)


printf seems to be quite slow. display and newline perform much better:

104857600 bytes (105 MB) copied, 14.7021 s, 7.1 MB/s

Gambit-C isn't better either:

104857600 bytes (105 MB) copied, 18.9284 s, 5.5 MB/s

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


[Chicken-users] file-read and let-values

2011-09-19 Thread Sascha Ziemann
Is this the prefered way to use the return values of file-read?

(let-values (((data bytes)) (apply values (file-read fileno size)))

It looks a bit wired. Why does file-read not return values directly if
the language supports them?

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