Re: [Chicken-users] [Q] How can I convert this lisp(SBCL) macro to chicken scheme?

2014-11-07 Thread Martin DeMello
check out the clojurian egg too: http://wiki.call-cc.org/eggref/4/clojurian

martin

On Thu, Nov 6, 2014 at 6:21 PM, Sungjin Chun chu...@gmail.com wrote:

 Thank you. Though I'm not sure on my code is in good style, I managed to
 convert my
 code to chicken scheme like this;

 (set-read-syntax!
  #\[
  (lambda (port)
(let loop ((c (peek-char port)) (exps '()))
  (cond ((eof-object? c)
 (error EOF encountered while parsing [ ... ] clause))
((char=? c #\])
 (read-char port) ;
 discard

 `(vector ,@(reverse exps)))
((char-whitespace? c)
 (read-char port) ; discard
 whitespaces

 (loop (peek-char port) exps))
(else
 (let ((exp (read port)))
   (loop (peek-char port)
 (cons exp exps

 (print (with-input-from-string [1 2 3 4 5] read))

 (set-read-syntax!
  #\{
  (lambda (port)
(let loop ((c (peek-char port)) (exps '()))
  (cond ((eof-object? c)
 (error EOF encountered while parsing [ ... ] clause))
((char=? c #\})
 (read-char port) ;
 discard

 `(alist-hash-table (chop (list ,@(reverse exps)) 2)))
((char-whitespace? c)
 (read-char port) ; discard
 whitespaces

 (loop (peek-char port) exps))
((char=? c #\,)
 (read-char port) ; discard
 whitespaces

 (loop (peek-char port) exps))
(else
 (let ((exp (read port)))
   (loop (peek-char port)
 (cons exp exps

 (print (with-input-from-string {'a 10, 'b 20, 'c 30} read))
 (print (with-input-from-string {'a 10 'b 20 'c 30} read))

 I post these code for people with similar needs like myself :-).


 On Fri, Nov 7, 2014 at 10:33 AM, Evan Hanson ev...@foldling.org wrote:

 Hi Sungjin,

 These are typically referred to as reader extensions in the Scheme
 world: http://api.call-cc.org/doc/library#sec:Reader_extensions

 You'll probabably want `set-read-syntax!` in particular:
 http://api.call-cc.org/doc/library/set-read-syntax!

 Cheers,

 Evan



 ___
 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] [Q] How can I convert this lisp(SBCL) macro to chicken scheme?

2014-11-07 Thread NeXT
Thank you, what I miss from clojure is its uniform or homoiconic(?) style of 
sequence accessing; so one does not have to check current sequence is whether 
list or vector or others. I'd like to create macro or something for this. :-)

Sent from my iPhone

 On Nov 7, 2014, at 5:16 PM, Martin DeMello martindeme...@gmail.com wrote:
 
 check out the clojurian egg too: http://wiki.call-cc.org/eggref/4/clojurian
 
 martin
 
 On Thu, Nov 6, 2014 at 6:21 PM, Sungjin Chun chu...@gmail.com wrote:
 Thank you. Though I'm not sure on my code is in good style, I managed to 
 convert my
 code to chicken scheme like this;
 
 (set-read-syntax!
  #\[
  (lambda (port)
(let loop ((c (peek-char port)) (exps '()))
  (cond ((eof-object? c)
 (error EOF encountered while parsing [ ... ] clause))
((char=? c #\])
 (read-char port) ; discard   
  

 `(vector ,@(reverse exps)))
((char-whitespace? c)
 (read-char port) ; discard whitespaces   
  

 (loop (peek-char port) exps))
(else
 (let ((exp (read port)))
   (loop (peek-char port)
 (cons exp exps
 
 (print (with-input-from-string [1 2 3 4 5] read))
 
 (set-read-syntax!
  #\{
  (lambda (port)
(let loop ((c (peek-char port)) (exps '()))
  (cond ((eof-object? c)
 (error EOF encountered while parsing [ ... ] clause))
((char=? c #\})
 (read-char port) ; discard   
  

 `(alist-hash-table (chop (list ,@(reverse exps)) 2)))
((char-whitespace? c)
 (read-char port) ; discard whitespaces   
  

 (loop (peek-char port) exps))
((char=? c #\,)
 (read-char port) ; discard whitespaces   
  

 (loop (peek-char port) exps))
(else
 (let ((exp (read port)))
   (loop (peek-char port)
 (cons exp exps
 
 (print (with-input-from-string {'a 10, 'b 20, 'c 30} read))
 (print (with-input-from-string {'a 10 'b 20 'c 30} read))
 
 I post these code for people with similar needs like myself :-).
 
 
 On Fri, Nov 7, 2014 at 10:33 AM, Evan Hanson ev...@foldling.org wrote:
 Hi Sungjin,
 
 These are typically referred to as reader extensions in the Scheme
 world: http://api.call-cc.org/doc/library#sec:Reader_extensions
 
 You'll probabably want `set-read-syntax!` in particular:
 http://api.call-cc.org/doc/library/set-read-syntax!
 
 Cheers,
 
 Evan
 
 
 ___
 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] [Q] How can I convert this lisp(SBCL) macro to chicken scheme?

2014-11-07 Thread Moritz Heidkamp
NeXT chu...@gmail.com writes:

 Thank you, what I miss from clojure is its uniform or homoiconic(?)
 style of sequence accessing; so one does not have to check current
 sequence is whether list or vector or others. I'd like to create macro
 or something for this. :-)

This is called a generic interface, it has nothing to do with
homoiconicity. For CHICKEN, the sequences egg[1] offers something like
this.

Moritz

[1] http://api.call-cc.org/doc/sequences


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


Re: [Chicken-users] [Q] How can I convert this lisp(SBCL) macro to chicken scheme?

2014-11-07 Thread NeXT
Wow, thank you. 

Sent from my iPhone

 On Nov 7, 2014, at 10:03 PM, Moritz Heidkamp mor...@twoticketsplease.de 
 wrote:
 
 NeXT chu...@gmail.com writes:
 
 Thank you, what I miss from clojure is its uniform or homoiconic(?)
 style of sequence accessing; so one does not have to check current
 sequence is whether list or vector or others. I'd like to create macro
 or something for this. :-)
 
 This is called a generic interface, it has nothing to do with
 homoiconicity. For CHICKEN, the sequences egg[1] offers something like
 this.
 
 Moritz
 
 [1] http://api.call-cc.org/doc/sequences

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


Re: [Chicken-users] [Q] How can I convert this lisp(SBCL) macro to chicken scheme?

2014-11-07 Thread Thomas Chust

On Fri, 7 Nov 2014, Moritz Heidkamp wrote:


NeXT chu...@gmail.com writes:


Thank you, what I miss from clojure is its uniform or homoiconic(?)
style of sequence accessing; so one does not have to check current
sequence is whether list or vector or others. I'd like to create macro
or something for this. :-)


This is called a generic interface, it has nothing to do with
homoiconicity. For CHICKEN, the sequences egg[1] offers something like
this.
[...]


Hello,

the SRFI-42 eager comprehensions also go in that direction and are also 
available as an egg for chicken.


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] [Q] How can I convert this lisp(SBCL) macro to chicken scheme?

2014-11-06 Thread Evan Hanson
Hi Sungjin,

These are typically referred to as reader extensions in the Scheme
world: http://api.call-cc.org/doc/library#sec:Reader_extensions

You'll probabably want `set-read-syntax!` in particular:
http://api.call-cc.org/doc/library/set-read-syntax!

Cheers,

Evan

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


Re: [Chicken-users] [Q] How can I convert this lisp(SBCL) macro to chicken scheme?

2014-11-06 Thread Sungjin Chun
Thank you. Though I'm not sure on my code is in good style, I managed to
convert my
code to chicken scheme like this;

(set-read-syntax!
 #\[
 (lambda (port)
   (let loop ((c (peek-char port)) (exps '()))
 (cond ((eof-object? c)
(error EOF encountered while parsing [ ... ] clause))
   ((char=? c #\])
(read-char port) ;
discard

`(vector ,@(reverse exps)))
   ((char-whitespace? c)
(read-char port) ; discard
whitespaces

(loop (peek-char port) exps))
   (else
(let ((exp (read port)))
  (loop (peek-char port)
(cons exp exps

(print (with-input-from-string [1 2 3 4 5] read))

(set-read-syntax!
 #\{
 (lambda (port)
   (let loop ((c (peek-char port)) (exps '()))
 (cond ((eof-object? c)
(error EOF encountered while parsing [ ... ] clause))
   ((char=? c #\})
(read-char port) ;
discard

`(alist-hash-table (chop (list ,@(reverse exps)) 2)))
   ((char-whitespace? c)
(read-char port) ; discard
whitespaces

(loop (peek-char port) exps))
   ((char=? c #\,)
(read-char port) ; discard
whitespaces

(loop (peek-char port) exps))
   (else
(let ((exp (read port)))
  (loop (peek-char port)
(cons exp exps

(print (with-input-from-string {'a 10, 'b 20, 'c 30} read))
(print (with-input-from-string {'a 10 'b 20 'c 30} read))

I post these code for people with similar needs like myself :-).


On Fri, Nov 7, 2014 at 10:33 AM, Evan Hanson ev...@foldling.org wrote:

 Hi Sungjin,

 These are typically referred to as reader extensions in the Scheme
 world: http://api.call-cc.org/doc/library#sec:Reader_extensions

 You'll probabably want `set-read-syntax!` in particular:
 http://api.call-cc.org/doc/library/set-read-syntax!

 Cheers,

 Evan

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