cross-compilation, part II - Re: [Chicken-users] cross compilation with 2.7

2007-11-05 Thread felix winkelmann
On 11/4/07, john [EMAIL PROTECTED] wrote:
 Hi, I wanted to update my cross compiled Chicken from 2.6 to 2.7 but ran
 into problems. I attempted a build with PLATFORM=linux but it borks at:

 gcc -fno-strict-aliasing -DHAVE_CHICKEN_CONFIG_H -c apply-hack.x86.s -o
 apply-hack.x86.o

 I am not sure what apply-hack does or what is needed for an ARM hack?


apply-hack is a piece of assembly to circumvent the 128-argument problem.
It is entirely optional, and a small script is used to find out the architecture
for the build system. In a cross-compilation setting this doesn't make much
sense, of course. Here you have to give the target arch manually.

I have updated

http://chicken.wiki.br/cross-compilation

for the new build system. You will need a tarball (make dist) from the
chicken repository trunk.


cheers,
felix


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


Re: [Chicken-users] stepwise visual execution of functions

2007-11-05 Thread felix winkelmann
On 11/4/07, Terrence Brannon [EMAIL PROTECTED] wrote:
 After I develop a function, I want to see what happens to the input
 data as it hits each step of the function to make sure it is working
 correctly. For example, in the following function:

 (define (mraze a)
   (let* ([unboxed-a (unbox-array a)]
  [unboxed-l (array-list unboxed-a)]
  [item-shapes (map item-shape unboxed-l)]
  [data-ranks (map my-array-rank unboxed-l)]
  )
 (if (all-equal? = item-shapes)
 (if (= (apply max data-ranks) 1)
 (apply rank-1 (flatten (map array-items unboxed-l)))
 #t)
 #f)))


 I would like to pass in a data-item, and then see the value of
 unboxed-a and then step once more and see the value of unboxed-l and
 so on, all the way through the procedure.

 Any suggestions for how to visually see what my functions are doing?

You can try the ,step command in csi.


cheers,
felix


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


Re: [Chicken-users] Re: chicken.pdf

2007-11-05 Thread felix winkelmann
Thanks, naturo. I have updated the documentation accordingly.


cheers,
felix


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


[Chicken-users] Re: Style Guide

2007-11-05 Thread Tobia Conforto
William Ramsay wrote:
 Is there such a thing as a Chicken/Scheme style guide? [...] If there
 is such a thing as teaching an old dog new tricks I'd like to try.

Your last sentence makes me think that you're referring to algorithm
design, not mere syntax style.  Things like learning to use closures and
continuations effectively, learning to express iterative processes with
recursive syntax, and so on.

If that's the case, I'm finding SICP[1] and The * Schemer series[2] very
interesting reads.  Even if you already know most of the concepts and
half the tricks in them, they are worth reading for the other half.


Tobia

[1] online at http://mitpress.mit.edu/sicp/
[2] by Daniel P. Friedman et al., available in most libraries and stores


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


Re: [Chicken-users] Re: Style Guide

2007-11-05 Thread Peter Bex
On Mon, Nov 05, 2007 at 12:16:12PM +0100, Tobia Conforto wrote:
 William Ramsay wrote:
  Is there such a thing as a Chicken/Scheme style guide? [...] If there
  is such a thing as teaching an old dog new tricks I'd like to try.
 
 Your last sentence makes me think that you're referring to algorithm
 design, not mere syntax style.  Things like learning to use closures and
 continuations effectively, learning to express iterative processes with
 recursive syntax, and so on.
 
 If that's the case, I'm finding SICP[1] and The * Schemer series[2] very
 interesting reads.  Even if you already know most of the concepts and
 half the tricks in them, they are worth reading for the other half.

+1 on that!
-- 
http://sjamaan.ath.cx
--
The process of preparing programs for a digital computer
 is especially attractive, not only because it can be economically
 and scientifically rewarding, but also because it can be an aesthetic
 experience much like composing poetry or music.
-- Donald Knuth


pgpmzs5rZvWL5.pgp
Description: PGP signature
___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] heap size or macro problem

2007-11-05 Thread Rick Taube

The first thing to check is whether you perform any Scheme-C calls
with callbacks into Scheme: if these are not properly declared as  
safe,

since this always (sooner or later) leads to trouble.


wow thanks so much you have saved us days of work with this tip! this  
is exactly what we are doing. a user scheme function gets added to a  
JUCE scheduling/scheme thread, which then does a callback on the  
fuctino at the correct time. during that callback the user's (scheme)  
function will certainly call into C again, for example sending midi  
notes to the output port. originally we were calling the user's  
function (the 'closure' var) from the scheme thread using C_callback  
like this:


{
  double nexttime ;
  C_word *elapsed_ptr;
  C_word elapsed_word;
  C_word closure;
  closure = CHICKEN_gc_root_ref(gcroot);
  elapsed_ptr = C_alloc(1);
  elapsed_word = C_flonum( elapsed_ptr, time - start);
  C_save( elapsed_word );
  nexttime = C_c_double( C_callback(closure, 1));
}

i *think* this code was working but the downside is that every user  
funcino has to be wrapped with error handling code to avoid crashes  
under the callback... so we replaced that first version with one that  
uses a define-external


(define-external (run_process (scheme-object closure) (double  
elapsed)) double

  ( closure elapsed))


that get called like this:

  nexttime = run_process( CHICKEN_gc_root_ref(closureGCRoot),  
time  - start);


which -- if it worked -- i think would be a better solution becuse  
the we can put the error handling code in the external point instead  
of inside every user function, eg:


(define-external ...)
  (with-no-errors ( closure  elapsed))



if these are not properly declared as safe,
since this always (sooner or later) leads to trouble.


so clearly we are not doing this right because nothing is declared as  
safe however I dont see in the docs how to declare the run_process as  
safe, can you help me out? or should we just use the first version  
and wrap each clouser with error proctection boilerplate?


thanks!
--rick


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


Re: [Chicken-users] heap size or macro problem

2007-11-05 Thread felix winkelmann
On 11/5/07, Rick Taube [EMAIL PROTECTED] wrote:

 so clearly we are not doing this right because nothing is declared as
 safe however I dont see in the docs how to declare the run_process as
 safe, can you help me out? or should we just use the first version
 and wrap each clouser with error proctection boilerplate?


I'm not sure yet that you do anything wrong. So this is an application
that embeds compiled Scheme code into a C/C++ app, right?
Do you run CHICKEN_run() once and does the Scheme code do a
(return-to host)? In this situation, you don't need the safe versions
of foreign-lambda[*] (I was refering to those, when I mentioned
safe, i.e. foreign-safe-lambda[*]). You need them when you have
Scheme code (embedded or not) that calls C that calls Scheme again.
So if you use foreign-lambda's in your code that call back into
Scheme, then replace them with foreign-safe-lambda.

Anyway, it's not trivial to get all this right, and the error messages
are often misleading.


cheers,
felix


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


Re: [Chicken-users] heap size or macro problem

2007-11-05 Thread Rick Taube

I'm not sure yet that you do anything wrong. So this is an application
that embeds compiled Scheme code into a C/C++ app, right?


yes this is correct. we are trying to embed Chicken in our JUCE GUI  
app for music.



Do you run CHICKEN_run() once and does the Scheme code do a
(return-to host)? In this situation, you don't need the safe  
versions

of foreign-lambda[*] (I was refering to those, when I mentioned
safe, i.e. foreign-safe-lambda[*]).


yes and yes. (return-to-host) is the last line of our  
ChickenBridge.scm file that we compiled to C++ and then compile/link  
with our program:


csc -c++ -embedded -t ChickenBridge.scm

Then, in our C++ app the scheduler's init method starts up Chicken  
like this, which includes chicken_run:


bool SchemeThread::init() {
  int res;
  C_word r;
  char buffer[8192];
  String text = T(Chicken Scheme);

  // init chicken...
  res = CHICKEN_initialize(0, 0, 0,  (void*)C_grace_toplevel);
  if (res==0) {
console-printError(T( Error: Chicken failed to initialize. 
\n));	

return false;
  }

  // run chicken...
  res = CHICKEN_run(NULL);
  if (res==0) {
console-printError(T( Error: Chicken failed to initialize. 
\n));	

return false;
  }

  // print chicken version info to Console Window:
  res = CHICKEN_eval_string_to_string( (char*)(chicken-version),  
buffer, 8192);

  if (res0)
text = text + T(, version ) + String(buffer).unquoted();
  text += T(\n(c) 2000-2007 Felix L. Winkelmann\n);
  console-printMessage(text);
  bzero(buffer, 8192);
  if (res==0) {
console-printError(T( Error: Chicken failed to initialize. 
\n));	

return false;
  }
  CHICKEN_eval_string((require-extension srfi-18), r);
  CHICKEN_eval_string((require-extension srfi-1), r);
  ..}



Anyway, it's not trivial to get all this right, and the error messages
are often misleading.


it sure isnt. we are *hoping* to call chicken funcs in realtime for  
music, our initial rough tests last week were showing that the GC  
doesnt really get in the way even with modest amounts of garbage  
being generated on callbacks happening every 50ms. but we wanted to  
get the error protection stuff in place so we could test with a  
real situation.


thanks!

--rick






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


Re: [Chicken-users] heap size or macro problem

2007-11-05 Thread Rick Taube

Can you run your application under valgrind?


sorry one important data point i forgot in my last posts:  im running  
on osx 10.4.10 PPC. we are also testing on an osx 10.4.10 Intel where  
this problem is not showing up. I could compile the whole system  
under linux, i had been waiting to see if we could get things going  
in osx first.


pinhead:~ hkt$ uname -a
Darwin pinhead.music.uiuc.edu 8.10.0 Darwin Kernel Version 8.10.0:  
Wed May 23 16:50:59 PDT 2007; root:xnu-792.21.3~1/RELEASE_PPC Power  
Macintosh powerpc




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


Re: [Chicken-users] Re: Style Guide

2007-11-05 Thread Mark Fredrickson
 William Ramsay wrote:
  Is there such a thing as a Chicken/Scheme style guide? [...] If there
  is such a thing as teaching an old dog new tricks I'd like to try.

 Your last sentence makes me think that you're referring to algorithm
 design, not mere syntax style.  Things like learning to use closures and
 continuations effectively, learning to express iterative processes with
 recursive syntax, and so on.

There is certainly a idiomatic style of Scheme, but I think the actual
style as defined by the layout of the source code matters as well.
Those two documents were useful reads to some who frets over such
issues (me).

Here's a related question for more experienced Schemers: In Dybvig, he
states that the define form:

(define square (lambda (x) (* x x)))

is to be preferred to

(define (square x) (* x x))

After reading that, I started using the first form religiously. Now
I'm not so sure. For no small part because the text editor I use
(TextMate) doesn't highlight the first form as a function definition
but does highlight the second form.

Anyone have an opinion? I'm not looking for an opinion, but perhaps a
tip as to why one method might prove more useful as I release code or
maintain code that I've already written.

TIA,
-M


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


[Chicken-users] Re: Style Guide

2007-11-05 Thread Tobia Conforto
Mark Fredrickson wrote:
 There is certainly a idiomatic style of Scheme, but I think the actual
 style as defined by the layout of the source code matters as well.
 Those two documents were useful reads to some who frets over such
 issues (me).

Yes, I'm correcting my style based on those documents too.


 Here's a related question for more experienced Schemers: In Dybvig, he
 states that the define form:
   (define square (lambda (x) (* x x)))
 is to be preferred to
   (define (square x) (* x x))
 After reading that, I started using the first form religiously. Now
 I'm not so sure.

I'm no experienced schemer, but I like the second form best because it
makes it visually clear how the function will be called: looking at
(square x) it's obvious what the parameters and their formal names are.

When I see a (square 3) later on in the code, I will recognize it
instantly (visually) as an application of (define (square x) ...)

Plus it's shorter.


Tobia


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


Re: [Chicken-users] Re: Style Guide

2007-11-05 Thread Sunnan

Mark Fredrickson wrote:


Here's a related question for more experienced Schemers: In Dybvig, he
states that the define form:

(define square (lambda (x) (* x x)))

is to be preferred to

(define (square x) (* x x))

After reading that, I started using the first form religiously. Now
I'm not so sure. For no small part because the text editor I use
(TextMate) doesn't highlight the first form as a function definition
but does highlight the second form.

  

The second form.
Shorter is better.
Always, always, always.

Sunnan


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


Re: cross-compilation, part II - Re: [Chicken-users] cross compilation with 2.7

2007-11-05 Thread john
Thanks Felix. I managed to build from the svn trunk for my Linux ARM
setup. I am having problems getting the cross Chicken running. I was
able to build it but I am not able to set the correct correct
compilers. In a previous version I specified them for the build with:

TARGET_CC=/home/john/moko/build/tmp/cross/bin/arm-angstrom-linux-gnueabi-gcc
TARGET_CXX=/home/john/moko/build/tmp/cross/bin/arm-angstrom-linux-gnueabi-g++

Incidently,

./arm-csc -cc-name reports:

arm=linux-gcc

which I guess is a meant to be 'arm-linux-gcc'.

Cheers,

John.

On 05/11/2007, felix winkelmann [EMAIL PROTECTED] wrote:
 On 11/4/07, john [EMAIL PROTECTED] wrote:
  Hi, I wanted to update my cross compiled Chicken from 2.6 to 2.7 but ran
  into problems. I attempted a build with PLATFORM=linux but it borks at:
 
  gcc -fno-strict-aliasing -DHAVE_CHICKEN_CONFIG_H -c apply-hack.x86.s -o
  apply-hack.x86.o
 
  I am not sure what apply-hack does or what is needed for an ARM hack?
 

 apply-hack is a piece of assembly to circumvent the 128-argument problem.
 It is entirely optional, and a small script is used to find out the 
 architecture
 for the build system. In a cross-compilation setting this doesn't make much
 sense, of course. Here you have to give the target arch manually.

 I have updated

 http://chicken.wiki.br/cross-compilation

 for the new build system. You will need a tarball (make dist) from the
 chicken repository trunk.


 cheers,
 felix



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


[Chicken-users] eggs tutorial

2007-11-05 Thread naruto canada
hi

I'm reading the part about tests dir and run.scm.
I've poke inside a few eggs, but couldn't figure out what should
run.scm return?
#t or #f ?

The web page needs to be amended to include expected return value for run.scm.
 http://chicken.wiki.br/eggs%20tutorial#tests 

Is it ok, if I simply list all my test cases in run.scm?
(use test)
(test . )
(test . )
(test . )
..

Thanks.


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


[Chicken-users] ok my first egg is ready

2007-11-05 Thread naruto canada
hi

ok my first egg is ready.
all test cases passed.
here it is:
http://downloads.sourceforge.net/math-linux/predicate-calculus.egg


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


Re: cross-compilation, part II - Re: [Chicken-users] cross compilation with 2.7

2007-11-05 Thread felix winkelmann
On 11/6/07, john [EMAIL PROTECTED] wrote:
 Thanks Felix. I managed to build from the svn trunk for my Linux ARM
 setup. I am having problems getting the cross Chicken running. I was
 able to build it but I am not able to set the correct correct
 compilers. In a previous version I specified them for the build with:

 TARGET_CC=/home/john/moko/build/tmp/cross/bin/arm-angstrom-linux-gnueabi-gcc
 TARGET_CXX=/home/john/moko/build/tmp/cross/bin/arm-angstrom-linux-gnueabi-g++

 Incidently,

 ./arm-csc -cc-name reports:

 arm=linux-gcc

 which I guess is a meant to be 'arm-linux-gcc'.

Hm. Could this be a typo in your make invocation? Can you build the
cross chicken once again, and send me a build log?


cheers,
felix


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


Re: [Chicken-users] eggs tutorial

2007-11-05 Thread felix winkelmann
On 11/6/07, naruto canada [EMAIL PROTECTED] wrote:
 hi

 I'm reading the part about tests dir and run.scm.
 I've poke inside a few eggs, but couldn't figure out what should
 run.scm return?
 #t or #f ?

 The web page needs to be amended to include expected return value for 
 run.scm.
  http://chicken.wiki.br/eggs%20tutorial#tests 

A failed test script should simply throw an error or exit with a non-zero
exit status.


 Is it ok, if I simply list all my test cases in run.scm?
 (use test)
 (test . )
 (test . )
 (test . )
 ..


Right.


cheers,
felix


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


Re: [Chicken-users] ok my first egg is ready

2007-11-05 Thread felix winkelmann
On 11/6/07, naruto canada [EMAIL PROTECTED] wrote:
 hi

 ok my first egg is ready.
 all test cases passed.
 here it is:
 http://downloads.sourceforge.net/math-linux/predicate-calculus.egg


Thanks, Naruto!

I have added the egg to the repository, it should be available soon.

BTW, the current egg count is 348. Two more to go!


cheers,
felix


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