[Chicken-users] Unit ports documentation needs an example or two for non-gods

2012-05-23 Thread Matt Welland
 (port-map FN THUNK)

where does the port go?

I was sort of hoping for something like this to work:

csi (define inp (open-input-file ~/.bashrc))
csi (define a (port-map inp read-line))
csi (close-input-file inp)

but it took guessing to figure out the intended usage. How about some
trivial examples in the docs?

By trial and error I figured this out:

(define a (with-input-from-file ~/.bashrc (lambda ()(port-map (lambda (x)
x) read-line

That is ugly. I just want to get a file into a list:

E.g. in Ruby:  foo=`cat ~/.bashrc`

port-fold doesn't improve it:

(define b (with-input-from-file ~/.bashrc (lambda ()(reverse (port-fold
cons '() read-line)

Is there an egg or unit for down-n-dirty, get-the-job-done-yesterday, screw
the right thing programming?

(use ducttape)
(define a (file-list ~/.bashrc))


Such a unit or egg deserves mention on the front page. I dug though the
docs and never did find an easy way to do what I want.
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Unit ports documentation needs an example or two for non-gods

2012-05-23 Thread Daniel Leslie
I'm personally not aware of any eggs that specifically match your request.
But there are these eggs, which I tend to use more often than others:

Misc Macros http://wiki.call-cc.org/eggref/4/miscmacros
More Macros http://wiki.call-cc.org/eggref/4/moremacros
lookup-table http://wiki.call-cc.org/eggref/4/lookup-table
Sequences http://wiki.call-cc.org/eggref/4/sequences
SRFI-99 http://wiki.call-cc.org/eggref/4/srfi-99

Less general, but still often useful:
SRFI-45 http://wiki.call-cc.org/eggref/4/srfi-45
lazy-seq http://wiki.call-cc.org/eggref/4/lazy-seq

-Dan

On Wed, May 23, 2012 at 6:35 AM, Matt Welland estifo...@gmail.com wrote:

  (port-map FN THUNK)

 where does the port go?

 I was sort of hoping for something like this to work:

 csi (define inp (open-input-file ~/.bashrc))
 csi (define a (port-map inp read-line))
 csi (close-input-file inp)

 but it took guessing to figure out the intended usage. How about some
 trivial examples in the docs?

 By trial and error I figured this out:

 (define a (with-input-from-file ~/.bashrc (lambda ()(port-map (lambda
 (x) x) read-line

 That is ugly. I just want to get a file into a list:

 E.g. in Ruby:  foo=`cat ~/.bashrc`

 port-fold doesn't improve it:

 (define b (with-input-from-file ~/.bashrc (lambda ()(reverse (port-fold
 cons '() read-line)

 Is there an egg or unit for down-n-dirty, get-the-job-done-yesterday,
 screw the right thing programming?

 (use ducttape)
 (define a (file-list ~/.bashrc))
 

 Such a unit or egg deserves mention on the front page. I dug though the
 docs and never did find an easy way to do what I want.

 ___
 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] Unit ports documentation needs an example or two for non-gods

2012-05-23 Thread Kevin Wortman
You can do that with

(call-with-input-file PATH read-lines)

or

(read-lines my-file.txt)

The latter comes from this page
http://wiki.call-cc.org/chicken-for-python-programmers
which documents a few down-and-dirty idioms.

Kevin

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


Re: [Chicken-users] segv with stty egg

2012-05-23 Thread Christian Kellermann
Hi Aaron!
* Aaron Patterson tenderl...@ruby-lang.org [120523 04:45]:

 I am trying to read from a tty with Chicken.  I've been messing around
 with the stty egg, and it seems to be segving on me.  Here is the script
 I'm using:

   https://gist.github.com/2772939

 I know I'm not using the stty egg correctly, but I don't think it should
 be segving in this case.  Thanks!

Hm, indeed a  crash is not nice!  Can you try  whether it also crashes
for you with the stty's trunk version?

Thanks!

Christian

--
9 out of 10 voices in my head say, that I am crazy,
one is humming.

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


Re: [Chicken-users] segv with stty egg

2012-05-23 Thread Mario Domenech Goulart
Hi,

On Wed, 23 May 2012 18:55:31 +0200 Christian Kellermann ck...@pestilenz.org 
wrote:

 * Aaron Patterson tenderl...@ruby-lang.org [120523 04:45]:

 I am trying to read from a tty with Chicken.  I've been messing around
 with the stty egg, and it seems to be segving on me.  Here is the script
 I'm using:

   https://gist.github.com/2772939

 I know I'm not using the stty egg correctly, but I don't think it should
 be segving in this case.  Thanks!

 Hm, indeed a  crash is not nice!  Can you try  whether it also crashes
 for you with the stty's trunk version?

There is no change in trunk since the latest stty release (0.2.2).

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] segv with stty egg

2012-05-23 Thread Aaron Patterson
On Wed, May 23, 2012 at 06:55:31PM +0200, Christian Kellermann wrote:
 Hi Aaron!
 * Aaron Patterson tenderl...@ruby-lang.org [120523 04:45]:
 
  I am trying to read from a tty with Chicken.  I've been messing around
  with the stty egg, and it seems to be segving on me.  Here is the script
  I'm using:
 
https://gist.github.com/2772939
 
  I know I'm not using the stty egg correctly, but I don't think it should
  be segving in this case.  Thanks!
 
 Hm, indeed a  crash is not nice!  Can you try  whether it also crashes
 for you with the stty's trunk version?

I'd be happy to test it.  Where do I find the svn repo?  I feel new in
the Chicken Scheme community, so I'm not sure where to locate this type
of information.  :-)

Eventually, I'd like to extend the egg to support cfsetispeed and
cfsetospeed so that I can read from a tty.

-- 
Aaron Patterson
http://tenderlovemaking.com/


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


Re: [Chicken-users] segv with stty egg

2012-05-23 Thread Christian Kellermann
* Aaron Patterson tenderl...@ruby-lang.org [120523 19:29]:
 On Wed, May 23, 2012 at 06:55:31PM +0200, Christian Kellermann wrote:
  Hi Aaron!
  * Aaron Patterson tenderl...@ruby-lang.org [120523 04:45]:
  
   I am trying to read from a tty with Chicken.  I've been messing around
   with the stty egg, and it seems to be segving on me.  Here is the script
   I'm using:
  
 https://gist.github.com/2772939
  
   I know I'm not using the stty egg correctly, but I don't think it should
   be segving in this case.  Thanks!
 
  Hm, indeed a  crash is not nice!  Can you try  whether it also crashes
  for you with the stty's trunk version?

My bad! I have had local modifications in my trunk's directory. I am
sorry for the confusion!

I will have a more closer look ;)

 I'd be happy to test it.  Where do I find the svn repo?  I feel new in
 the Chicken Scheme community, so I'm not sure where to locate this type
 of information.  :-)

in general you will find this egg in the svn repo here:
 https://code.call-cc.org/svn/chicken-eggs/release/4/stty/trunk
user: anonymous, no password for read-only access

 Eventually, I'd like to extend the egg to support cfsetispeed and
 cfsetospeed so that I can read from a tty.

Cool!

Kind regards,

Christian

--
9 out of 10 voices in my head say, that I am crazy,
one is humming.

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


Re: [Chicken-users] segv with stty egg

2012-05-23 Thread Christian Kellermann
Maybe the following patch is a suitable solution?

Index: stty.scm
===
--- stty.scm(revision 26267)
+++ stty.scm(working copy)
@@ -367,16 +367,16 @@
 ;; high-level interface

 (define (stty . args)
+
+  (and-let* ((port (if (and (pair? args) (port? (car args)))
+   (car args)
+   (current-input-port)))
+ (attr (get-terminal-attributes port))
+ (iflag (term-attrs-iflag attr))
+ (oflag (term-attrs-oflag attr))
+ (cflag (term-attrs-cflag attr))
+ (lflag (term-attrs-lflag attr)))

-  (let* ((port (if (and (pair? args) (port? (car args)))
-   (car args)
-   (current-input-port)))
- (attr (get-terminal-attributes port))
- (iflag (term-attrs-iflag attr))
- (oflag (term-attrs-oflag attr))
- (cflag (term-attrs-cflag attr))
- (lflag (term-attrs-lflag attr)))
-
 ;; parse change requests
 (let lp ((lst (if (and (pair? args) (port? (car args))) (cdr args) args))
  (flag #t))


--
9 out of 10 voices in my head say, that I am crazy,
one is humming.

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


Re: [Chicken-users] segv with stty egg

2012-05-23 Thread Mario Domenech Goulart
Hi Aaron,

On Wed, 23 May 2012 10:29:36 -0700 Aaron Patterson tenderl...@ruby-lang.org 
wrote:

 On Wed, May 23, 2012 at 06:55:31PM +0200, Christian Kellermann wrote:
 Hi Aaron!
 * Aaron Patterson tenderl...@ruby-lang.org [120523 04:45]:
 
  I am trying to read from a tty with Chicken.  I've been messing around
  with the stty egg, and it seems to be segving on me.  Here is the script
  I'm using:
 
https://gist.github.com/2772939
 
  I know I'm not using the stty egg correctly, but I don't think it should
  be segving in this case.  Thanks!
 
 Hm, indeed a  crash is not nice!  Can you try  whether it also crashes
 for you with the stty's trunk version?

 I'd be happy to test it.  Where do I find the svn repo?  I feel new in
 the Chicken Scheme community, so I'm not sure where to locate this type
 of information.  :-)

Sorry, maybe the docs are a bit scattered, but since we are used to it,
we end up not noticing some omissions or bad organization (we actually
know the organization is bad, but fixing it, you know...).

Here's a quick summary:

* The CHICKEN core (compiler, interpreter, runtime system, profiler,
  eggs manager) code is maintained in a git repository (see
  http://code.call-cc.org for info about how to get it).

* Eggs can be hosted by the subversion repository at call-cc.org or,
  more recently, on remote VCSs (see
  http://wiki.call-cc.org/releasing-your-egg).  When eggs are not hosted
  by the svn repository at call-cc.org, you probably can find the egg
  repository location in the egg documentation
  (http://wiki.call-cc.org/egg/the-egg).  If the egg author has not
  provided that information in the egg documentation (he/she should),
  you can find it out by looking at the egg-locations file
  (https://anonym...@code.call-cc.org/svn/chicken-eggs/release/4/egg-locations
  -- empty password)

* You can also get eggs source code with chicken-install:

  $ chicken-install -r the-egg

  If you want some specific version:

  $ chicken-install -r the-egg:the-version

  If you want to get the tests too:

  $ chicken-install -r -test the-egg


tl;dr: http://code.call-cc.org/ provides guidelines about how to obtain
code hosted on call-cc.org.  For eggs hosted remotely, check the egg
documentation or the egg-locations file.  You can quickly and
VCS-agnostically get eggs source code with chicken-install.


 Eventually, I'd like to extend the egg to support cfsetispeed and
 cfsetospeed so that I can read from a tty.

Nice.  Thanks for your interest in contributing.


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] Unit ports documentation needs an example or two for non-gods

2012-05-23 Thread Matt Welland
Thanks Kevin and Daniel, great hints. Much appreciated.

On Wed, May 23, 2012 at 7:48 AM, Kevin Wortman kwort...@gmail.com wrote:

 You can do that with

 (call-with-input-file PATH read-lines)

 or

 (read-lines my-file.txt)

 The latter comes from this page
 http://wiki.call-cc.org/chicken-for-python-programmers
 which documents a few down-and-dirty idioms.

 Kevin

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