[Chicken-users] 4.8.0.5 syntax weirdness

2014-03-10 Thread Sandra Snan
Dear chicken-users;
I have a simple program that does most of its heavy lifting at compile
time.

To demonstrate the issue, I've written two stubs (as simple as I could
make them but still show the issue I'm having).

File number one is called ticket-stub.scm:
-8
(use s (srfi 1))

(define-syntax create-tickets
  (ir-macro-transformer
   (lambda (f i c)
 `(list
   ,@(filter-map
  (lambda (x)
(if (s-contains? enemy- x)
#f
(s-prepend friendly- x)))
  cells)

(print (first (create-tickets)))
-8

It should print out the word friendly-horse after this:
csc -extend ticket-stub-compilation.scm ticket-stub.scm  ./ticket_stub

Here is its sister file, ticket-stub-compilation.scm:

-8
(use s (srfi 1) anaphora)

(define (gen-cells)
  ;; In the real version of this, this is not only an expensive
  ;; operation but it's also dependent on io and data that I only want
  ;; to read at compile time. (It's going through a large collection of
  ;; XML files and selecting a small subset of that for this program.)
  ;; For the purposes of this stub, it's simply some strings.

  (let ((n (random 10)))
(if (zero? n)
'()
(cons (if (odd? n) enemy-horse horse) (gen-cells)

(define cells
  (let big-cells ((cells (gen-cells)))
(if ( (length cells) 3)
cells
(big-cells (gen-cells)
-8

When compiled with this version of Chicken:
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)

I get this error:
Error: during expansion of (create-tickets ...) - unbound variable: s-contains?
followed by the call history, and then
Error: shell command terminated with non-zero exit status 17920: 
'/usr/bin/chicken' 'ticket-stub.scm' -output-file 'ticket-stub.c' -extend 
ticket-stub-compilation.scm


However, when compiled with this version of Chicken:
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-05 on gladstone.duckburg.org (Linux)

We get our friendly-horse.

Am I doing something wrong or have I found a bug?

(Weird that there’s an EOL space on the line “Version 4.7.0 ” but I
guess that’s some Debian quirk.)
4.7.0 is the version that’s in Debian Stable.

Sandra

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


Re: [Chicken-users] 4.8.0.5 syntax weirdness

2014-03-10 Thread Peter Bex
On Mon, Mar 10, 2014 at 01:26:08PM +0100, Sandra Snan wrote:
 Dear chicken-users;
 I have a simple program that does most of its heavy lifting at compile
 time.
 
 To demonstrate the issue, I've written two stubs (as simple as I could
 make them but still show the issue I'm having).
 
 File number one is called ticket-stub.scm:
 -8
 (use s (srfi 1))
 
 (define-syntax create-tickets
   (ir-macro-transformer
(lambda (f i c)
  `(list
,@(filter-map
 (lambda (x)
   (if (s-contains? enemy- x)
   #f
   (s-prepend friendly- x)))
 cells)
 
 (print (first (create-tickets)))
 -8

Hello Sandra,

The above program uses the procedures provided by the s egg at
expansion time, so you need to load and import them at the syntax level:

(begin-for-syntax (use s))

Or, in newer CHICKENs:

(use-for-syntax s)

The reason it worked with 4.7.0 and not with 4.8.0 is that this is
really a bug: at compile time, procedures imported for runtime should
not be available unless they're explicitly imported.  That's the
entry in 4.8.0's NEWS: Fixed a bug that caused imported identifiers
to leak into the macroexpansion/compile-time environment

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] 4.8.0.5 syntax weirdness

2014-03-10 Thread Sandra Snan
On Mon, 10 Mar 2014 13:54:03 +0100, Peter Bex peter@xs4all.nl wrote:
 On Mon, Mar 10, 2014 at 01:26:08PM +0100, Sandra Snan wrote:
  Dear chicken-users;
  I have a simple program that does most of its heavy lifting at compile
  time.
 
  To demonstrate the issue, I've written two stubs (as simple as I could
  make them but still show the issue I'm having).

(I realized after sending that one of the stubs could randomly generate
a list without any “friendly” strings. The full program is
deterministic, it just needs to trawl through a lot of data.)

 The above program uses the procedures provided by the s egg at
 expansion time, so you need to load and import them at the syntax level:

Thank you so much, Peter.

 (begin-for-syntax (use s))

Unfortunately, this gives me
“Error: unbound variable: use”

 Or, in newer CHICKENs:
 
 (use-for-syntax s)

and this gives me “Error: unbound variable: use-for-syntax”

Sandra

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


[Chicken-users] Review my Caesar Cipher?

2014-03-10 Thread Daniel Carrera
Hello,

I found a Scheme implementation of the Caesar cipher on Rosetta Code. It
said This was written by a novice, please review... So I reviewed it, and
basically rewrote it.

I think my version is much better (clearer) but since I too am a novice, I
feel bad removing the novice warning. Could someone who has used Scheme
longer than two weeks have a quick look at my work and tell me if I can
remove the warning (or make corrections if my code is not idiomatic or
something)?

My version(s):

http://rosettacode.org/wiki/Caesar_cipher#Scheme

Previous version:

http://rosettacode.org/mw/index.php?title=Caesar_cipheroldid=177675#scheme

Cheers,
Daniel.
-- 
When an engineer says that something can't be done, it's a code phrase that
means it's not fun to do.
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Review my Caesar Cipher?

2014-03-10 Thread Phil Bewig
I would use an auxiliary function char-plus to add or subtract an offset to
a character:

(define (caesar str n)
  (define (char-plus c)
(let ((alpha ABCDEFGHIJKLMNOPQRSTUVWXYZ))
  (if (not (char-alphabetic? c)) c
(let ((i (- (char-integer (char-upcase c)) 65)))
  (string-ref alpha (modulo (+ i n) 26))
  (list-string (map char-plus (string-list str

Then here are your two examples; decryption is just encryption by the
negative:

 (caesar To craunch the marmoset. 1)
UP DSBVODI UIF NBSNPTFU.
 (caesar UP DSBVODI UIF NBSNPTFU. -1)
TO CRAUNCH THE MARMOSET.


On Mon, Mar 10, 2014 at 9:51 AM, Daniel Carrera dcarr...@gmail.com wrote:

 Hello,

 I found a Scheme implementation of the Caesar cipher on Rosetta Code. It
 said This was written by a novice, please review... So I reviewed it, and
 basically rewrote it.

 I think my version is much better (clearer) but since I too am a novice, I
 feel bad removing the novice warning. Could someone who has used Scheme
 longer than two weeks have a quick look at my work and tell me if I can
 remove the warning (or make corrections if my code is not idiomatic or
 something)?

 My version(s):

 http://rosettacode.org/wiki/Caesar_cipher#Scheme

 Previous version:

 http://rosettacode.org/mw/index.php?title=Caesar_cipheroldid=177675#scheme

 Cheers,
 Daniel.
 --
 When an engineer says that something can't be done, it's a code phrase
 that means it's not fun to do.

 ___
 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] Review my Caesar Cipher?

2014-03-10 Thread Peter Bex
On Mon, Mar 10, 2014 at 10:26:56AM -0500, Phil Bewig wrote:
 I would use an auxiliary function char-plus to add or subtract an offset to
 a character:
 
 (define (caesar str n)
   (define (char-plus c)
 (let ((alpha ABCDEFGHIJKLMNOPQRSTUVWXYZ))
   (if (not (char-alphabetic? c)) c
 (let ((i (- (char-integer (char-upcase c)) 65)))
   (string-ref alpha (modulo (+ i n) 26))
   (list-string (map char-plus (string-list str

If you're using srfi-13, you might as well change the final line to use
string-map:  (string-map char-plus str)

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] Review my Caesar Cipher?

2014-03-10 Thread Jörg F. Wittenberger

Am 10.03.2014 15:51, schrieb Daniel Carrera:

Hello,

I found a Scheme implementation of the Caesar cipher on Rosetta Code. 
It said This was written by a novice, please review... So I reviewed 
it, and basically rewrote it.


I think my version is much better (clearer)


I tend to agree that your version is clearer.  Especially because it's 
shorter and uses fewer let-scopes.


As this is an exercise, I'd take an issue with the use of list-ref in 
the replacements.  List-ref is O(n) in the size of the list. Once should 
try to avoid that.


A first alternative would be string-ref.  That would be O(1).  As long 
as your Scheme does not use something like UTF-8 as string 
representation.  So maybe it would be the best to resort to something like:


(define  replacements(apply vector (string-list  rotated)))
 
(define  (caesar char)

  (let  ((index(string-index alphabet char)))
(if  index
(vector-ref replacements index)
char)))  ; Not found = Copy verbatim.


Notice: I replaced the second occurrence of (string-index alphabet 
char) with index - the variable the result was of the first call was 
already bound to.  I'm leaving it here as an exercise to you to figure 
out why.  ;-)



Your second version brings up a completely different consideration. The 
task implement a caesar chipher is slightly underspecified. That is, 
actually it's OK, since it would imply that you are supposed to produce 
a general solution.  And your first version does.


You second version depends on the mapping from characters to integers.  
It will only work on such mappings, which are accidentally 
compatible to ASCII for upper case letters.  I'm using quotes here, 
because the days are long gone, when you had a reasonable chance to get 
your hands on a system using incompatible encodings like

http://en.wikipedia.org/wiki/DEC_Radix-50
Otherwise I'd prefer the second version for using less memory.

Note however: if you wanted the your cipher to be easily adapted to more 
general mappings (e.g. be applicable to other character sets than upper 
case ASCII compatible - which would easily be parts of unicode or say 
HTML entities like uuml;) then the argument is reversed and your first 
version would be the better fit.


but since I too am a novice, I feel bad removing the novice warning. 
Could someone who has used Scheme longer than two weeks have a quick 
look at my work and tell me if I can remove the warning (or make 
corrections if my code is not idiomatic or something)?


My version(s):

http://rosettacode.org/wiki/Caesar_cipher#Scheme

Previous version:

http://rosettacode.org/mw/index.php?title=Caesar_cipheroldid=177675#scheme

Cheers,
Daniel.
--
When an engineer says that something can't be done, it's a code phrase 
that means it's not fun to do.



___
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] Review my Caesar Cipher?

2014-03-10 Thread Phil Bewig
I used only the procedures provided by RnRS, instead of loading SRFI-13,
but you could use string-map if you want to. For those who prefer to roll
their own, here is a simple version of string-map! that mutates the string
in place:

(define (string-map! f str)
  (do ((i 0 (+ i 1))) ((= i (string-length str)) str)
(string-set! str i (f (string-ref str i)

Or you could convert to a list, perform the mapping, and convert back, as I
did in my original version of the function. With string-map!, the caesar
function changes to this:

(define (caesar str n)
  (define (char-plus c)
(let ((alpha ABCDEFGHIJKLMNOPQRSTUVWXYZ))
  (if (not (char-alphabetic? c)) c
(let ((i (- (char-integer (char-upcase c)) 65)))
  (string-ref alpha (modulo (+ i n) 26))
  (string-map! char-plus str))

For purposes of Rosetta Code, it's probably better to avoid SRFI-13 and
stay with RnRS, as in my first version of the function.


On Mon, Mar 10, 2014 at 10:31 AM, Peter Bex peter@xs4all.nl wrote:

 On Mon, Mar 10, 2014 at 10:26:56AM -0500, Phil Bewig wrote:
  I would use an auxiliary function char-plus to add or subtract an offset
 to
  a character:
 
  (define (caesar str n)
(define (char-plus c)
  (let ((alpha ABCDEFGHIJKLMNOPQRSTUVWXYZ))
(if (not (char-alphabetic? c)) c
  (let ((i (- (char-integer (char-upcase c)) 65)))
(string-ref alpha (modulo (+ i n) 26))
(list-string (map char-plus (string-list str

 If you're using srfi-13, you might as well change the final line to use
 string-map:  (string-map char-plus str)

 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] Review my Caesar Cipher?

2014-03-10 Thread Daniel Carrera
Thanks. I think it's fair to use SRF-13. Now that I learned some character
functions from Phil, I think the following is nice and compact:

(define (caesar char)
  (if (not (char-alphabetic? char)) char ; Return other chars verbatim.
  (let ((i (- (char-integer (char-upcase char)) 65)))
(integer-char (+ 65 (modulo (+ i key) 26))

(print (string-map caesar msg))

Cheers,
Daniel.



On 10 March 2014 16:31, Peter Bex peter@xs4all.nl wrote:

 On Mon, Mar 10, 2014 at 10:26:56AM -0500, Phil Bewig wrote:
  I would use an auxiliary function char-plus to add or subtract an offset
 to
  a character:
 
  (define (caesar str n)
(define (char-plus c)
  (let ((alpha ABCDEFGHIJKLMNOPQRSTUVWXYZ))
(if (not (char-alphabetic? c)) c
  (let ((i (- (char-integer (char-upcase c)) 65)))
(string-ref alpha (modulo (+ i n) 26))
(list-string (map char-plus (string-list str

 If you're using srfi-13, you might as well change the final line to use
 string-map:  (string-map char-plus str)

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




-- 
When an engineer says that something can't be done, it's a code phrase that
means it's not fun to do.
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Review my Caesar Cipher?

2014-03-10 Thread John Cowan
Daniel Carrera scripsit:

 (define (caesar char)
   (if (not (char-alphabetic? char)) char ; Return other chars verbatim.
   (let ((i (- (char-integer (char-upcase char)) 65)))
 (integer-char (+ 65 (modulo (+ i key) 26))
 
 (print (string-map caesar msg))

This isn't i18n-safe, because char-alphabetic? can return #t on
non-Latin letters.  Convert to an integer first and make sure it's in
the safe range.  Then add a comment to the effect that this assumes a
Scheme in which char-integer and integer-char preserve the ASCII range.
(Almost all Schemes do so, but it's not required by R5RS.)

General comments not relevant to this code:

1) Rolling your own string-map is tricky, because of the R7RS requirement
that a call/cc from the mapping function work correctly:

If multiple returns occur from `string-map`, the values returned
by earlier returns are not mutated.

2) `Use` is Chicken-specific.  There is no fully standard way to
load/import a module prior to R6RS/R7RS, but at least `require-extension`
(which is also implemented in Chicken) is the subject of SRFI 55.

-- 
MEET US AT POINT ORANGE AT MIDNIGHT BRING YOUR DUCK OR PREPARE TO FACE WUGGUMS
John Cowan  co...@ccil.org  http://www.ccil.org/~cowan

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


Re: [Chicken-users] 4.8.0.5 syntax weirdness

2014-03-10 Thread Sandra Snan
I couldn't quite get this to work:

ticket-stub.scm
8
(use s (srfi 1))

(begin-for-syntax
 (import chicken)
 (use s (srfi)))

(define-syntax create-tickets
  (ir-macro-transformer
   (lambda (f i c)
 `(list
   ,@(filter-map
  (lambda (x)
(if (s-contains? enemy- x)
#f
(s-prepend friendly- x)))
  cells)

(print (first (create-tickets)))

8
ticket-stub-compilation.scm
8
(use s (srfi 1) anaphora)

(define (gen-cells)
  ;; In the real version of this, this is not only an expensive
  ;; operation but it's also dependent on io and data that I only want
  ;; to read at compile time.
  ;; For the purposes of this stub, it's simply some strings.

  (let ((n (random 10)))
(if (zero? n)
'()
(cons (if (odd? n) enemy-horse horse) (gen-cells)

(define cells (cons horse (gen-cells)))
8


It still can't find s-contains.
If I move the entire (define-syntax create-tickets ...) sexp to the end
of begin-for-syntax, it can't find create-tickets when called later.

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


Re: [Chicken-users] Review my Caesar Cipher?

2014-03-10 Thread Daniel Carrera
On 10 March 2014 17:10, John Cowan co...@mercury.ccil.org wrote:

 This isn't i18n-safe, because char-alphabetic? can return #t on
 non-Latin letters.  Convert to an integer first and make sure it's in
 the safe range.  Then add a comment to the effect that this assumes a
 Scheme in which char-integer and integer-char preserve the ASCII range.
 (Almost all Schemes do so, but it's not required by R5RS.)

 ...

 2) `Use` is Chicken-specific.  There is no fully standard way to
 load/import a module prior to R6RS/R7RS, but at least `require-extension`
 (which is also implemented in Chicken) is the subject of SRFI 55.


I am trying to write an R7RS-compliant version. R7RS would give me
import, as well as char-integer and integer-char. The problem I'm
having is that my code does not work when I compile it, or when I use csi
-s, but it works perfectly well when I paste it directly into the csi
REPL. Here is what I have:

;
; Unicode-safe. Requires an R7RS-compliant Scheme.
;
(import (srfi 13)) ; String library.

(define msg The quick brown fox jumps over the lazy fox.)
(define key 13)

(define (caesar char)
  (define A (char-integer #\A))
  (define Z (char-integer #\Z))
  (define a (char-integer #\a))
  (define z (char-integer #\z))
  (define c (char-integer char))
  (cond ((and (= c A) (= c Z)) (integer-char (+ A (modulo (+ key (- c
A)) 26
((and (= c a) (= c z)) (integer-char (+ a (modulo (+ key (- c
a)) 26
(else char))) ; Return other characters verbatim.

(print (string-map caesar msg))



When I compile this and run it, I get an error saying that string-map is
not defined. Same thing happens with csi -s. So clearly it is not loading
SRFI-13... Any ideas?

Cheers,
Daniel.
-- 
When an engineer says that something can't be done, it's a code phrase that
means it's not fun to do.
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] 4.8.0.5 syntax weirdness

2014-03-10 Thread Peter Bex
On Mon, Mar 10, 2014 at 07:37:36PM +0100, Sandra Snan wrote:
 I couldn't quite get this to work:
 
 It still can't find s-contains.
 If I move the entire (define-syntax create-tickets ...) sexp to the end
 of begin-for-syntax, it can't find create-tickets when called later.

This is unfortunate: I just tested your code and it works with 4.8.4, but
not with 4.8.0.5.  Most likely this was a large change we considered too
dangerous to include in the stability branch.  I'm not sure which of
the many changes it was that fixed this.

I'm afraid your only options are to stick with 4.7.0 or use the
4.8.4 development snapshot (or git master) until 4.9.0 has been
released. The good news is that both the development snapshot and
master should be pretty stable since we're this close to a release.

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] Review my Caesar Cipher?

2014-03-10 Thread Daniel Carrera
On 10 March 2014 20:04, Daniel Carrera dcarr...@gmail.com wrote:

 I am trying to write an R7RS-compliant version. R7RS would give me
 import, as well as char-integer and integer-char. The problem I'm
 having is that my code does not work when I compile it, or when I use csi
 -s, but it works perfectly well when I paste it directly into the csi REPL.


After a tip from Erik, I have isolated the issue. The (import) only works
correctly if you first run (use posix). My REPL was loading posix because I
loaded readline. The following code compiles and runs correctly:

(use posix)

;
; Unicode-safe. Requires an R7RS-compliant Scheme.
;
(import (srfi 13)) ; String library.

(define msg The quick brown fox jumps over the lazy fox.)
(define key 13)

(define (caesar char)
  (define A (char-integer #\A))
  (define Z (char-integer #\Z))
  (define a (char-integer #\a))
  (define z (char-integer #\z))
  (define c (char-integer char))
  (cond ((and (= c A) (= c Z)) (integer-char (+ A (modulo (+ key (- c
A)) 26
((and (= c a) (= c z)) (integer-char (+ a (modulo (+ key (- c
a)) 26
(else char))) ; Return other characters verbatim.

(print (string-map caesar msg))



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


Re: [Chicken-users] Review my Caesar Cipher?

2014-03-10 Thread Alex Shinn
On Tue, Mar 11, 2014 at 6:16 AM, Daniel Carrera dcarr...@gmail.com wrote:


 On 10 March 2014 20:04, Daniel Carrera dcarr...@gmail.com wrote:

 I am trying to write an R7RS-compliant version. R7RS would give me
 import, as well as char-integer and integer-char. The problem I'm
 having is that my code does not work when I compile it, or when I use csi
 -s, but it works perfectly well when I paste it directly into the csi REPL.


 After a tip from Erik, I have isolated the issue. The (import) only works
 correctly if you first run (use posix). My REPL was loading posix because I
 loaded readline. The following code compiles and runs correctly:

 (use posix)

 ;
 ; Unicode-safe. Requires an R7RS-compliant Scheme.
 ;
 (import (srfi 13)) ; String library.

 (define msg The quick brown fox jumps over the lazy fox.)
 (define key 13)

 (define (caesar char)
   (define A (char-integer #\A))
   (define Z (char-integer #\Z))
   (define a (char-integer #\a))
   (define z (char-integer #\z))
   (define c (char-integer char))
   (cond ((and (= c A) (= c Z)) (integer-char (+ A (modulo (+ key (- c
 A)) 26
 ((and (= c a) (= c z)) (integer-char (+ a (modulo (+ key (- c
 a)) 26
 (else char))) ; Return other characters verbatim.


(integer-char
 (cond ((= A c Z) (+ A (modulo (+ key (- c A)) 26)))
  ((= a c z) (+ a (modulo (+ key (- c A)) 26)))
  (else c)))



 (print (string-map caesar msg))



 Cheers,
 Daniel.


 ___
 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] R7RS: (current-jiffy) and (jiffies-per-second)

2014-03-10 Thread Alex Shinn
On Sun, Mar 9, 2014 at 7:51 PM, Daniel Carrera dcarr...@gmail.com wrote:

 Hello,

 I hope nobody minds an R7RS question. This list seems to have people
 knowledgeable of R7RS. It seems weird that R7RS would specify the functions:


There's also scheme-repo...@scheme-reports.org but
I doubt people mind here.

(current-jiffy)  --  An exact integer representing the number of jiffies
 (arbitrary unit of time) since some arbitrary epoch.

 (jiffies-per-second) -- Integer representing the number of jiffies in one
 second.


 What could possibly be the value of these functions, given that R7RS
 already specifies (current-second) as the number of seconds since the Unix
 epoch? This seems like an oddly useless concept for a language that tries
 to be minimalist.


There are actually a number of motivations for this.
(current-second) is expensive, and in the presence
of NTP not guaranteed to be monotonic.  It will also
generally cons to return a bignum or flonum, whereas
current-jiffy could always return fixnums.

In general, for timing you want to use jiffies, and
for calendar operations you want want seconds.

The utility is not disputed.  Whether this belongs
in the small language is debatable (as is _everything_),
but it's there and is easy to implement.

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


Re: [Chicken-users] R7RS: (current-jiffy) and (jiffies-per-second)

2014-03-10 Thread John Cowan
Alex Shinn scripsit:

 current-jiffy could always return fixnums.

Alas, only if you are in the sweet spot of:

1) programs don't run for too long

2) fixnums are sufficiently large

3) jiffies aren't too precise

On a 32-bit system with microsecond resolution (which does not necessarily
mean microsecond precision), (current-jiffy) returns bignums after 17
minutes, assuming the largest fixnum is 2^30.  I tried to get this fixed
at the last minute by allowing jiffies to wrap around, but it didn't
pass the WG.

-- 
A few times, I did some exuberant stomping about,   John Cowan
like a hippo auditioning for Riverdance, though co...@ccil.org
I stopped when I thought I heard something at   http://ccil.org/~cowan
the far side of the room falling over in rhythm
with my feet.  --Joseph Zitt

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


Re: [Chicken-users] 4.8.0.5 syntax weirdness

2014-03-10 Thread Jim Ursetto
This is the fix:

commit f8230a466ce3a86f360178f115fb62ee124448b9
Author: Peter Bex peter@xs4all.nl
Date:   Sun Jun 30 18:50:09 2013 +0200

Fix meta-evaluation to actually take place in the meta environment and add 
tests

Signed-off-by: Christian Kellermann ck...@pestilenz.org


It seems pretty simple and applies cleanly to stability and tests out ok.  Do 
you think I should apply it?

Jim

On Mar 10, 2014, at 2:08 PM, Peter Bex peter@xs4all.nl wrote:

 On Mon, Mar 10, 2014 at 07:37:36PM +0100, Sandra Snan wrote:
 I couldn't quite get this to work:
 
 It still can't find s-contains.
 If I move the entire (define-syntax create-tickets ...) sexp to the end
 of begin-for-syntax, it can't find create-tickets when called later.
 
 This is unfortunate: I just tested your code and it works with 4.8.4, but
 not with 4.8.0.5.  Most likely this was a large change we considered too
 dangerous to include in the stability branch.  I'm not sure which of
 the many changes it was that fixed this.
 
 I'm afraid your only options are to stick with 4.7.0 or use the
 4.8.4 development snapshot (or git master) until 4.9.0 has been
 released. The good news is that both the development snapshot and
 master should be pretty stable since we're this close to a release.
 
 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 mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users