Re: [Chicken-users] Named let*

2013-05-28 Thread Michele La Monaca
On Tue, May 28, 2013 at 2:06 AM, Jim Ursetto zbignie...@gmail.com wrote:

 On May 27, 2013, at 4:14 PM, Michele La Monaca mikele.chic...@lamonaca.net 
 wrote:

 So writing down the options, we have:

 (let* loop ((i (random N)) (ch (string-ref buf i)))
  (do-something)
  (if (some-condition-is-true)
(loop (+ i 1)
  (string-ref buf (+ i 1)

 vs.

 (let ((start (random N)))
  (let loop ((i start) (ch (string-ref buf start)))
(do-something)
(if (some-condition-is-true)
  (loop (+ i 1)
(string-ref buf (+ i 1))

 vs.

 (let ((ch '()))
  (let loop ((i (random N)))
(set! ch (string-ref buf i))
(do-something)
(if (some-condition-is-true)
  (loop (+ i 1)


 Why not

 (let loop ((i (random N)))
   (let ((ch (string-ref buf i)))
(do-something)
(if (some-condition-is-true)
  (loop (+ i 1)


Yes, sure. Thanks for spotting the omission.

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


Re: [Chicken-users] POP3 egg: issue and possible fix.

2013-05-28 Thread Felix
From: Geoffrey lordgeoff...@optusnet.com.au
Subject: [Chicken-users] POP3 egg: issue and possible fix.
Date: Sat, 25 May 2013 15:13:35 +1000

 The commercial mail server i connect to sends a simple +OK after a
 USER. It doesn't have any trailing characters, so this match from the
 pop3.scm fetch proc fails:
 (match (string-match (\\+OK|\\-ERR) (.*) ln)
 
 I changed it (somewhat inexpertly) to:
 (match (string-match (\\+OK|\\-ERR) *(.*) ln)
 
 and it works.
 

Thanks a lot. I applied the fix, see pop3 1.5.


cheers,
felix

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


[Chicken-users] Is chicken supported on 32 bit Linux?

2013-05-28 Thread John Long
On the latest stable 4.8.0.3:

Is chicken supported on 32 bit Linux systems? The make and make install went
fine but make check blew up early. Looking over the mailing list archives
somebody else got the same problem way back when and realized it was because
of some x86_64 test case but nobody ever said whether the tests are broken
or whether this requires 64 bit support.

Can somebody make a definitive comment on this please? If this is supposed
to work I'll run it again and post the output.

Thanks

/jl

-- 
ASCII ribbon campaign ( ) Powered by Lemote Fuloong
 against HTML e-mail   X  Loongson MIPS and OpenBSD
   and proprietary/ \http://www.mutt.org
 attachments /   \  Code Blue or Go Home!
 Encrypted email preferred  PGP Key 2048R/DA65BC04 

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


Re: [Chicken-users] Is chicken supported on 32 bit Linux?

2013-05-28 Thread Christian Kellermann
* John Long codeb...@inbox.lv [130528 16:12]:
 On the latest stable 4.8.0.3:
 
 Is chicken supported on 32 bit Linux systems? The make and make install went
 fine but make check blew up early. Looking over the mailing list archives
 somebody else got the same problem way back when and realized it was because
 of some x86_64 test case but nobody ever said whether the tests are broken
 or whether this requires 64 bit support.


CHICKEN works fine on 32 bit. I am sorry that it does not work for
you, could you please provide us with a transcript of what you did
and how it fails?

Thanks,

Christian

-- 
In the world, there is nothing more submissive and weak than
water. Yet for attacking that which is hard and strong, nothing can
surpass it. --- Lao Tzu

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


Re: [Chicken-users] Is chicken supported on 32 bit Linux?

2013-05-28 Thread John Cowan
John Long scripsit:

 Is chicken supported on 32 bit Linux systems? 

Yes, it definitely is.  The problem is that we don't have a proper build
farm with sufficiently diverse machines, so support tends to crumble at
awkward moments.

-- 
John Cowan  co...@ccil.org  http://ccil.org/~cowan
If he has seen farther than others,
it is because he is standing on a stack of dwarves.
--Mike Champion, describing Tim Berners-Lee (adapted)

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


Re: [Chicken-users] Is chicken supported on 32 bit Linux?

2013-05-28 Thread Mario Domenech Goulart
Hi John,

On Tue, 28 May 2013 14:11:41 + John Long codeb...@inbox.lv wrote:

 On the latest stable 4.8.0.3:

 Is chicken supported on 32 bit Linux systems?

Yes.

 The make and make install went fine but make check blew up early.

What is the error you get?

 Looking over the mailing list archives somebody else got the same
 problem way back when and realized it was because of some x86_64 test
 case but nobody ever said whether the tests are broken or whether this
 requires 64 bit support.

 Can somebody make a definitive comment on this please? If this is supposed
 to work I'll run it again and post the output.

Yes, it is supposed to work.  Some tests related to symbol GC may fail
occasionally, but otherwise everything is supposed to work.  Please,
send us the make check output if you get errors again.

Best wishes.
Mario
-- 
http://parenteses.org/mario

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


Re: [Chicken-users] Is chicken supported on 32 bit Linux?

2013-05-28 Thread Mario Domenech Goulart
On Tue, 28 May 2013 10:15:21 -0400 John Cowan co...@mercury.ccil.org wrote:

 John Long scripsit:

 Is chicken supported on 32 bit Linux systems? 

 Yes, it definitely is.  The problem is that we don't have a proper build
 farm with sufficiently diverse machines, so support tends to crumble at
 awkward moments.

Actually, the only official build farm we have happens to be 32-bit
Linux . :-)

Best wishes.
Mario
-- 
http://parenteses.org/mario

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


Re: [Chicken-users] Is chicken supported on 32 bit Linux?

2013-05-28 Thread John Maxwell
On 05/28/13 10:11:41, John Long wrote:
 On the latest stable 4.8.0.3:
 
[snip]

Haven't tried 4.8.0.3, but 4.8.0.1 builds and installs fine, and I'm 
using it for a non-trivial app, which also works fine.

-John

--
John Maxwell  KB3VLL  j...@jmaxhome.com

Speaking just for me, I don't think I have Linux blinders on my
eyes. I can see other platforms, but I *choose* to ignore them on the
theory that if I ignore them hard enough they will go away.

This theory is obviously crazy. However, it also appears to be working.

— Eric S. Raymond

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


Re: [Chicken-users] Is chicken supported on 32 bit Linux?

2013-05-28 Thread John Long
Hi Christian,

Here's the part of the test that crashed. If you need the prior stuff just
let me know, I didn't want to post too hugely to the list!

Thanks!

/jl

 library tests ...
../chicken library-tests.scm -output-file a.c -verbose -include-path .. 
-specialize

Warning: in local unknown procedure,
  in local unknown procedure,
  in toplevel unknown procedure:
  (library-tests.scm:27) in procedure call to `finite?', expected argument #1 
of type `number', but was given an argument of type `symbol'

Warning: in local unknown procedure,
  in local unknown procedure,
  in toplevel unknown procedure:
  (library-tests.scm:51) in procedure call to `exact?', expected argument #1 of 
type `number', but was given an argument of type `symbol'

Warning: in local unknown procedure,
  in local unknown procedure,
  in toplevel unknown procedure:
  (library-tests.scm:55) in procedure call to `inexact?', expected argument #1 
of type `number', but was given an argument of type `symbol'

Warning: in local unknown procedure,
  in local unknown procedure,
  in toplevel unknown procedure:
  (library-tests.scm:95) in procedure call to `even?', expected argument #1 of 
type `number', but was given an argument of type `symbol'

Warning: in local unknown procedure,
  in local unknown procedure,
  in toplevel unknown procedure:
  (library-tests.scm:96) in procedure call to `odd?', expected argument #1 of 
type `number', but was given an argument of type `symbol'

Warning: in local unknown procedure,
  in local unknown procedure,
  in toplevel unknown procedure:
  (library-tests.scm:167) in procedure call to `min', expected argument #1 of 
type `number', but was given an argument of type `symbol'

Warning: in local unknown procedure,
  in local unknown procedure,
  in toplevel unknown procedure:
  (library-tests.scm:168) in procedure call to `max', expected argument #1 of 
type `number', but was given an argument of type `symbol'
gcc a.c -o a.o -c  -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H 
-DC_ENABLE_PTABLES -O3 -fomit-frame-pointer -I.. -I/usr/local/include/chicken
rm a.c
gcc a.o -o a.out -L.. -L/usr/local/lib  -Wl,-R/usr/local/lib -lchicken -lm 
-ldl
rm a.o

Error: (library-tests.scm:210) assertion failed: (= (sin 42.0) (fpsin 42.0))

Call history:

library-tests.scm:198: number-string 
library-tests.scm:198: g846   
library-tests.scm:198: number-string 
library-tests.scm:198: g846   
library-tests.scm:198: number-string 
library-tests.scm:198: g846   
library-tests.scm:198: number-string 
library-tests.scm:198: g846   
library-tests.scm:198: number-string 
library-tests.scm:198: g846   
library-tests.scm:198: number-string 
library-tests.scm:198: g846   
library-tests.scm:198: number-string 
library-tests.scm:198: g846   
library-tests.scm:198: number-string 
library-tests.scm:210: ##sys#error  --
make[1]: *** [check] Error 70
make[1]: Leaving directory `/home/dev01/builds/chicken-4.8.0.3'
make: *** [check] Error 2

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


Re: [Chicken-users] Is chicken supported on 32 bit Linux?

2013-05-28 Thread John Cowan
Mario Domenech Goulart scripsit:

 Actually, the only official build farm we have happens to be 32-bit
 Linux . :-)

Yeah, I was actually thinking of my poor half-abandoned Cygwin.  :-)

-- 
And it was said that ever after, if any John Cowan
man looked in that Stone, unless he had a   co...@ccil.org
great strength of will to turn it to other  http://ccil.org/~cowan
purpose, he saw only two aged hands withering
in flame.   --The Pyre of Denethor

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


Re: [Chicken-users] Is chicken supported on 32 bit Linux?

2013-05-28 Thread Christian Kellermann
* John Long codeb...@inbox.lv [130528 16:25]:
 Hi Christian,
 
 Here's the part of the test that crashed. If you need the prior stuff just
 let me know, I didn't want to post too hugely to the list!

Yes, some more info would be nice. Did you just download the 4.8.0.3
tarball untarred it, ran make  make install  make check?

What have been your build steps?

-- 
In the world, there is nothing more submissive and weak than
water. Yet for attacking that which is hard and strong, nothing can
surpass it. --- Lao Tzu

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


Re: [Chicken-users] Is chicken supported on 32 bit Linux?

2013-05-28 Thread John Long
On Tue, May 28, 2013 at 04:36:11PM +0200, Christian Kellermann wrote:
 * John Long codeb...@inbox.lv [130528 16:25]:
  Hi Christian,
  
  Here's the part of the test that crashed. If you need the prior stuff just
  let me know, I didn't want to post too hugely to the list!
 
 Yes, some more info would be nice. Did you just download the 4.8.0.3
 tarball untarred it, ran make  make install  make check?

Yes, except I didn't know how to tell the makefile to use -O3 so I changed
the C_COMPILER_OPTIMIZATION_OPTIONS after the else in Makefile.linux to
match the line before the else.

 
 What have been your build steps?

make PLATFORM=linux
su
make PLATFORM=linux install
ctrl-d to exit to user shell
make PLATFORM=linux check

What should I attach?

Thanks

/jl

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


Re: [Chicken-users] Is chicken supported on 32 bit Linux?

2013-05-28 Thread John Long
On Tue, May 28, 2013 at 02:36:58PM +, Mario Domenech Goulart wrote:
 Hey John
 
 On Tue, 28 May 2013 14:25:09 + John Long codeb...@inbox.lv wrote:
 
  Warning: in local unknown procedure,
in local unknown procedure,
in toplevel unknown procedure:
(library-tests.scm:168) in procedure call to `max', expected argument #1 
  of type `number', but was given an argument of type `symbol'
  gcc a.c -o a.o -c  -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H 
  -DC_ENABLE_PTABLES -O3 -fomit-frame-pointer -I.. 
  -I/usr/local/include/chicken
  rm a.c
  gcc a.o -o a.out -L.. -L/usr/local/lib  -Wl,-R/usr/local/lib -lchicken 
  -lm -ldl
 
 How did you call make to build, install and check chicken?

make PLATFORM=linux
su
make PLATFORM=linux install
exit
make PLATFORM=linux check

 
 Do you have libchicken.so in /usr/local/lib?

Yes, it is a symlink to libchicken.so.6 also in /usr/local/lib

 If so, is it the one installed by chicken-4.8.0.3?

Yes, it has today's date and time on it.

Thanks.

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


Re: [Chicken-users] Is chicken supported on 32 bit Linux?

2013-05-28 Thread Peter Bex
On Tue, May 28, 2013 at 02:25:09PM +, John Long wrote:
 Hi Christian,
 
 Here's the part of the test that crashed. If you need the prior stuff just
 let me know, I didn't want to post too hugely to the list!
 
 Error: (library-tests.scm:210) assertion failed: (= (sin 42.0) (fpsin 42.0))

fpsin expands pretty much to a direct call to the C sin() function, while
sin is wrapped in a function.

It could be that your compiler is performing some optimization which causes
this value to be (slightly?) different.

If it's possible, could you try it on a different version of your C
compiler (or another C compiler entirely), and/or tell us your compiler's
version?

Cheers,
Peter
-- 
http://www.more-magic.net

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


Re: [Chicken-users] Is chicken supported on 32 bit Linux?

2013-05-28 Thread Mario Domenech Goulart
Hey John

On Tue, 28 May 2013 14:25:09 + John Long codeb...@inbox.lv wrote:

 Warning: in local unknown procedure,
   in local unknown procedure,
   in toplevel unknown procedure:
   (library-tests.scm:168) in procedure call to `max', expected argument #1 of 
 type `number', but was given an argument of type `symbol'
 gcc a.c -o a.o -c  -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H 
 -DC_ENABLE_PTABLES -O3 -fomit-frame-pointer -I.. 
 -I/usr/local/include/chicken
 rm a.c
 gcc a.o -o a.out -L.. -L/usr/local/lib  -Wl,-R/usr/local/lib -lchicken 
 -lm -ldl

How did you call make to build, install and check chicken?

Do you have libchicken.so in /usr/local/lib?  If so, is it the one
installed by chicken-4.8.0.3?

Best wishes.
Mario
-- 
http://parenteses.org/mario

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


Re: [Chicken-users] Is chicken supported on 32 bit Linux?

2013-05-28 Thread Christian Kellermann
* John Long codeb...@inbox.lv [130528 16:48]:
 On Tue, May 28, 2013 at 04:36:11PM +0200, Christian Kellermann wrote:
  * John Long codeb...@inbox.lv [130528 16:25]:
   Hi Christian,
   
   Here's the part of the test that crashed. If you need the prior stuff just
   let me know, I didn't want to post too hugely to the list!
  
  Yes, some more info would be nice. Did you just download the 4.8.0.3
  tarball untarred it, ran make  make install  make check?
 
 Yes, except I didn't know how to tell the makefile to use -O3 so I changed
 the C_COMPILER_OPTIMIZATION_OPTIONS after the else in Makefile.linux to
 match the line before the else.

This may indicate a compiler optimisation breaking assumptions in
our code. Does it work for you when you leave the values as is?

Thanks,

Christian

-- 
In the world, there is nothing more submissive and weak than
water. Yet for attacking that which is hard and strong, nothing can
surpass it. --- Lao Tzu

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


Re: [Chicken-users] Is chicken supported on 32 bit Linux?

2013-05-28 Thread Peter Bex
On Tue, May 28, 2013 at 02:47:15PM +, John Long wrote:
 On Tue, May 28, 2013 at 04:36:11PM +0200, Christian Kellermann wrote:
  Yes, some more info would be nice. Did you just download the 4.8.0.3
  tarball untarred it, ran make  make install  make check?
 
 Yes, except I didn't know how to tell the makefile to use -O3 so I changed
 the C_COMPILER_OPTIMIZATION_OPTIONS after the else in Makefile.linux to
 match the line before the else.

Can you try without optimization options, before we go on a wild
goose chase?

Cheers,
Peter
-- 
http://www.more-magic.net

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


Re: [Chicken-users] Is chicken supported on 32 bit Linux?

2013-05-28 Thread John Long
On Tue, May 28, 2013 at 04:49:48PM +0200, Peter Bex wrote:
 On Tue, May 28, 2013 at 02:25:09PM +, John Long wrote:
  Hi Christian,
  
  Here's the part of the test that crashed. If you need the prior stuff just
  let me know, I didn't want to post too hugely to the list!
  
  Error: (library-tests.scm:210) assertion failed: (= (sin 42.0) (fpsin 42.0))
 
 fpsin expands pretty much to a direct call to the C sin() function, while
 sin is wrapped in a function.
 
 It could be that your compiler is performing some optimization which causes
 this value to be (slightly?) different.

It sounds like you nailed it. The tests run fine at -Os but fail at -O2 and
-O3.

 If it's possible, could you try it on a different version of your C
 compiler (or another C compiler entirely), and/or tell us your compiler's
 version?

It's vanilla gcc 4.7.1.

I'm ok for now but I would like it to work at least at -O2. Seems like gcc
(almost) always works at -O2!

/jl

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


Re: [Chicken-users] Is chicken supported on 32 bit Linux?

2013-05-28 Thread John Long
On Tue, May 28, 2013 at 05:04:31PM +0200, Christian Kellermann wrote:
 * John Long codeb...@inbox.lv [130528 16:48]:
  On Tue, May 28, 2013 at 04:36:11PM +0200, Christian Kellermann wrote:
   * John Long codeb...@inbox.lv [130528 16:25]:
Hi Christian,

Here's the part of the test that crashed. If you need the prior stuff 
just
let me know, I didn't want to post too hugely to the list!
   
   Yes, some more info would be nice. Did you just download the 4.8.0.3
   tarball untarred it, ran make  make install  make check?
  
  Yes, except I didn't know how to tell the makefile to use -O3 so I changed
  the C_COMPILER_OPTIMIZATION_OPTIONS after the else in Makefile.linux to
  match the line before the else.
 
 This may indicate a compiler optimisation breaking assumptions in
 our code. Does it work for you when you leave the values as is?

I didn't dream this up, as you know the makefile has provisions for -Os and
-O3 so I ASSumed somebody tested that! ;-)

It builds fine under -Os, O2, and O3 but the tests fail here at -O2 and -O3.

Thanks.

/jl

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


Re: [Chicken-users] Is chicken supported on 32 bit Linux?

2013-05-28 Thread Peter Bex
On Tue, May 28, 2013 at 03:19:00PM +, John Long wrote:
 On Tue, May 28, 2013 at 04:49:48PM +0200, Peter Bex wrote:
  It could be that your compiler is performing some optimization which causes
  this value to be (slightly?) different.
 
 It sounds like you nailed it. The tests run fine at -Os but fail at -O2 and
 -O3.
 
 It's vanilla gcc 4.7.1.
 
 I'm ok for now but I would like it to work at least at -O2. Seems like gcc
 (almost) always works at -O2!

Well, possibly the tests are wrong (flonum equality is Hard).
I'll have a look and see if this can be improved.
If it's indeed an optimization that causes a small difference in
flonums, it shouldn't cause any problems in practice so you should
be able to compile with -O3 and have no trouble.

Cheers,
Peter
-- 
http://www.more-magic.net

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


Re: [Chicken-users] Is chicken supported on 32 bit Linux?

2013-05-28 Thread Peter Bex
On Tue, May 28, 2013 at 07:20:14PM +0200, Peter Bex wrote:
 Well, possibly the tests are wrong (flonum equality is Hard).
 I'll have a look and see if this can be improved.
 If it's indeed an optimization that causes a small difference in
 flonums, it shouldn't cause any problems in practice so you should
 be able to compile with -O3 and have no trouble.

I just tested with -O3 on NetBSD/amd64 (gcc 4.5.3) and also on
Linux/i686 (Debian gcc 4.3.2-1.1) and all tests pass, with and
without DEBUGBUILD=1.

For now I'd say this is a problem with your particular gcc version.
If you or someone else can reproduce this and come up with a patch
that would be great.

You don't have to edit Makefiles BTW, you can easily force -O3 by running
gmake C_COMPILER_OPTIMIZATION_OPTIONS=-O3 ...
You can also pass OPTIMIZE_FOR_SPEED=1, which is a catchall setting.

If you want to let this stick around, config.make is the place to
add these settings.

Cheers,
Peter
-- 
http://www.more-magic.net

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


[Chicken-users] Protocol Buffers for CHICKEN

2013-05-28 Thread Thomas Chust
Hello,

during the CHICKEN spring thing in Cologne I started to work on a new
egg [1] implementing the protocol buffer [2] serialization format, which
is now in a usable and tested state.

If you don't need or want to use a specific schema for your data, you
can use the protobuf egg as a generic serialization solution that
produces platform-independent binary representations of (almost) any
CHICKEN values:

  $ cat source.scm
  (require-library protobuf)
  (import protobuf-generic)
  (serialize (lambda (x) (print (* 2 x
  $ csi -s source.scm lambda.pbf
  $ cat sink.scm
  (require-library protobuf)
  (import protobuf-generic)
  ((deserialize) 42)
  $ csi -s sink.scm lambda.pbf
  84

The serialized data can be read by other protocol buffer enabled
applications, it may not have the most convenient structure, though.

So if you have a need to communicate with other software that uses
protocol buffer definitions, you can use the protoc compiler plugin that
comes with this egg to generate a CHICKEN binding automatically from
existing schema definitions:

  $ cat person.proto
  package person;
  message Person {
required int32 id = 1;
required string name = 2;
optional string email = 3;
  }
  $ protoc --proto_path=. --chicken_out=. person.proto
  $ cat test.scm
  (require-library protobuf)
  (include person.scm)
  (import protobuf person)
  (serialize (make-person id: 42 name: Jane Doe))
  $ csi -s test.scm | \
   protoc --proto_path=. person.proto --decode=person.Person
  id: 42
  name: Jane Doe

Deserialization is just as simple with a call to (deserialize person).
The protobuf messages are represented as SRFI-99 records in CHICKEN that
can be manipulated as usual. Enumeration values are represented as symbols.

If you're interested, check the egg documentation for advanced features
and give the library a try :-)

Ciao,
Thomas


--
[1] https://wiki.call-cc.org/eggref/4/protobuf
[2] http://protobuf.googlecode.com/


-- 
When C++ is your hammer, every problem looks like your thumb.


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


Re: [Chicken-users] Protocol Buffers for CHICKEN

2013-05-28 Thread Dan Leslie

This is very welcome!

I wonder if this would be useful for storing data in a posix shared 
memory block...


-Dan

On 5/28/2013 3:15 PM, Thomas Chust wrote:

Hello,

during the CHICKEN spring thing in Cologne I started to work on a new
egg [1] implementing the protocol buffer [2] serialization format, which
is now in a usable and tested state.

If you don't need or want to use a specific schema for your data, you
can use the protobuf egg as a generic serialization solution that
produces platform-independent binary representations of (almost) any
CHICKEN values:

   $ cat source.scm
   (require-library protobuf)
   (import protobuf-generic)
   (serialize (lambda (x) (print (* 2 x
   $ csi -s source.scm lambda.pbf
   $ cat sink.scm
   (require-library protobuf)
   (import protobuf-generic)
   ((deserialize) 42)
   $ csi -s sink.scm lambda.pbf
   84

The serialized data can be read by other protocol buffer enabled
applications, it may not have the most convenient structure, though.

So if you have a need to communicate with other software that uses
protocol buffer definitions, you can use the protoc compiler plugin that
comes with this egg to generate a CHICKEN binding automatically from
existing schema definitions:

   $ cat person.proto
   package person;
   message Person {
 required int32 id = 1;
 required string name = 2;
 optional string email = 3;
   }
   $ protoc --proto_path=. --chicken_out=. person.proto
   $ cat test.scm
   (require-library protobuf)
   (include person.scm)
   (import protobuf person)
   (serialize (make-person id: 42 name: Jane Doe))
   $ csi -s test.scm | \
protoc --proto_path=. person.proto --decode=person.Person
   id: 42
   name: Jane Doe

Deserialization is just as simple with a call to (deserialize person).
The protobuf messages are represented as SRFI-99 records in CHICKEN that
can be manipulated as usual. Enumeration values are represented as symbols.

If you're interested, check the egg documentation for advanced features
and give the library a try :-)

Ciao,
Thomas


--
[1] https://wiki.call-cc.org/eggref/4/protobuf
[2] http://protobuf.googlecode.com/





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


Re: [Chicken-users] Protocol Buffers for CHICKEN

2013-05-28 Thread Thomas Chust
On 2013-05-29 00:32, Dan Leslie wrote:
 [...]
 I wonder if this would be useful for storing data in a posix shared
 memory block...
 [...]

Hello Dan,

that is certainly possible, you would just combine serialize and
call-with-output-string to obtain data you can copy into a shared buffer
and call-with-input-string plus deserialize to extract the stored value
on the receiving side.

However, shared memory between processes or threads on the same machine
has the advantage that one can place data in native formats in there
without having to care about endianness issues etc. So perhaps
object-evict and friends would be more efficient in this case.

The protobuf serialization could be quite useful for distributed
computing applications. Combining serialization of thunks with network
transport and some cryptographic authentication scheme yields you could
quickly construct a secure remote compute job submission server or a
distributed map reduce network, for example.

Ciao,
Thomas


-- 
When C++ is your hammer, every problem looks like your thumb.


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


Re: [Chicken-users] Protocol Buffers for CHICKEN

2013-05-28 Thread Dan Leslie

Huh, now that is useful!
https://wiki.call-cc.org/man/4/Unit%20lolevel#object-evict

Still, if I ever have call to use pshm for ipc between chicken and 
not-chicken workers then this egg would probably be useful.


Thanks again,
-Dan

On 5/28/2013 5:24 PM, Thomas Chust wrote:

On 2013-05-29 00:32, Dan Leslie wrote:

[...]
I wonder if this would be useful for storing data in a posix shared
memory block...
[...]

Hello Dan,

that is certainly possible, you would just combine serialize and
call-with-output-string to obtain data you can copy into a shared buffer
and call-with-input-string plus deserialize to extract the stored value
on the receiving side.

However, shared memory between processes or threads on the same machine
has the advantage that one can place data in native formats in there
without having to care about endianness issues etc. So perhaps
object-evict and friends would be more efficient in this case.

The protobuf serialization could be quite useful for distributed
computing applications. Combining serialization of thunks with network
transport and some cryptographic authentication scheme yields you could
quickly construct a secure remote compute job submission server or a
distributed map reduce network, for example.

Ciao,
Thomas





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