[Chicken-hackers] [PATCH] Move around {rename, delete}-file and a question about module for inexact

2017-09-10 Thread Peter Bex
Hi all,

Here's a straightforward patch to move those two procedures from
library.scm to file.scm.

I tried to move {file,directory}-exists? as well, but it seems
there are a few places which use it, and that would mean eval
will depend on file, irregex and posix, which I think is a bit
too heavy of a dependency.  I'm not sure how to fix this properly.

Also, a quick question: I noticed that finite?, infinite?, nan?
are in (scheme inexact) in r7rs.  Unfortunately, that module
also holds exp, sqrt, [as]sin, [as]cos, [as]tan and log, which
are all r5rs procedures.

Given that we're trying to put r7rs-like procedures under similar
namespace (but with scheme replaced by chicken) that creates a small
inconsistency; (chicken base) would hold finite?, infinite? and nan?
but they're really in (scheme inexact) in r7rs.  This might cause
confusion for users who are familiar with r7rs.  I don't know
how to solve that in a satisfactory way, unless we want to add a
module alias for it, so that some procedures are defined in
(chicken base) and scheme but re-exported by (chicken inexact).
What do you all think?

Cheers,
Peter
From 3b2cd55dea9dda88491a8693d6c40a1e12424ef9 Mon Sep 17 00:00:00 2001
From: Peter Bex 
Date: Sun, 10 Sep 2017 17:22:19 +0200
Subject: [PATCH] Move delete-file and rename-file from library.scm to file.scm

Nothing really depends on it, so we can move them without problems.

Fix up csc.scm's dependencies while we're at it (it also gets a new
dependency on file.import.scm)
---
 chicken.import.scm |  2 --
 csc.scm|  5 +++--
 file.scm   | 18 ++
 library.scm| 20 
 rules.make |  8 ++--
 5 files changed, 27 insertions(+), 26 deletions(-)

diff --git a/chicken.import.scm b/chicken.import.scm
index ad4b677f..06212515 100644
--- a/chicken.import.scm
+++ b/chicken.import.scm
@@ -54,7 +54,6 @@
cplxnum?
current-error-port
(current-exception-handler . chicken.condition#current-exception-handler)
-   delete-file
directory-exists?
(dynamic-load-libraries . chicken.load#dynamic-load-libraries)
enable-warnings
@@ -155,7 +154,6 @@
quotient&remainder
ratnum?
(register-feature! . chicken.platform#register-feature!)
-   rename-file
(repository-path . chicken.platform#repository-path)
(require . chicken.load#require)
return-to-host
diff --git a/csc.scm b/csc.scm
index 23241fac..15882f27 100644
--- a/csc.scm
+++ b/csc.scm
@@ -29,12 +29,13 @@
 
 (import scheme
 chicken
-chicken.posix
+	chicken.file
 	chicken.foreign
 	chicken.format
 chicken.io
-chicken.process
 	chicken.pathname
+chicken.posix
+chicken.process
 	chicken.string)
 
 (include "egg-environment.scm")
diff --git a/file.scm b/file.scm
index f9f42949..69b76949 100644
--- a/file.scm
+++ b/file.scm
@@ -104,12 +104,30 @@ EOF
 	(apply ##sys#signal-hook type loc (string-append msg " - " (strerror rn)) args) ) ) ) )
 
 
+(define (delete-file filename)
+  (##sys#check-string filename 'delete-file)
+  (unless (eq? 0 (##core#inline "C_delete_file" (##sys#make-c-string filename 'delete-file)))
+(##sys#update-errno)
+(##sys#signal-hook
+ #:file-error 'delete-file
+ (##sys#string-append "cannot delete file - " strerror) filename) )
+  filename)
+
 ;;; Like `delete-file', but does nothing if the file doesn't exist:
 
 (define delete-file*
   (lambda (file)
 (and (file-exists? file) (delete-file file
 
+(define (rename-file old new)
+  (##sys#check-string old 'rename-file)
+  (##sys#check-string new 'rename-file)
+  (unless (eq? 0 (##core#inline "C_rename_file" (##sys#make-c-string old 'rename-file) (##sys#make-c-string new)))
+(##sys#update-errno)
+(##sys#signal-hook
+ #:file-error 'rename-file
+ (##sys#string-append "cannot rename file - " strerror) old new) )
+  new)
 
 ;;; Directory management:
 
diff --git a/library.scm b/library.scm
index d190fd03..d75635a9 100644
--- a/library.scm
+++ b/library.scm
@@ -2897,26 +2897,6 @@ EOF
   (##sys#values (##sys#slot port 4) (##sys#slot port 5))
   (##sys#error 'port-position "cannot compute position of port" port) ) )
 
-(define (delete-file filename)
-  (##sys#check-string filename 'delete-file)
-  (unless (eq? 0 (##core#inline "C_delete_file" (##sys#make-c-string filename 'delete-file)))
-(##sys#update-errno)
-(##sys#signal-hook
- #:file-error 'delete-file
- (##sys#string-append "cannot delete file - " strerror) filename) )
-  filename)
-
-(define (rename-file old new)
-  (##sys#check-string old 'rename-file)
-  (##sys#check-string new 'rename-file)
-  (unless (eq? 0 (##core#inline "C_rename_file" (##sys#make-c-string old 'rename-file) (##sys#make-c-string new)))
-(##sys#update-errno)
-(##sys#signal-hook
- #:file-error 'rename-file
- (##sys#string-append "cannot rename file - " strerror) old new) )
-  new)
-
-
 ;;; Decorate procedure with arbitrary data
 ;
 ; warning: may modify proc,

Re: [Chicken-hackers] [PATCH] Move around {rename, delete}-file and a question about module for inexact

2017-09-10 Thread Peter Bex
On Sun, Sep 10, 2017 at 05:33:16PM +0200, Peter Bex wrote:
> Given that we're trying to put r7rs-like procedures under similar
> namespace (but with scheme replaced by chicken) that creates a small
> inconsistency; (chicken base) would hold finite?, infinite? and nan?
> but they're really in (scheme inexact) in r7rs.

This same inconsistency crops up in (scheme lazy), which has
delay, delay-force, force, promise? and make-promise, whereas
the scheme module has delay and force.

Again, we could put delay-force, promise? and make-promise into
(chicken base) _and_ make an aliasing module (chicken lazy)
that has both the extended and r5rs procedures, but that seems
awkward and annoying when you import both; you'd get constant
warnings about re-importing identifiers.  OTOH, putting it just
under (chicken base) might result in the aforementioned confusion
for people familiar with r7rs.

Cheers,
Peter


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


Re: [Chicken-hackers] [PATCH] Move around {rename, delete}-file and a question about module for inexact

2017-09-10 Thread John Cowan
On Sun, Sep 10, 2017 at 11:40 AM, Peter Bex  wrote:

This same inconsistency crops up in (scheme lazy), which has
> delay, delay-force, force, promise? and make-promise, whereas
> the scheme module has delay and force.
>

As the main inventor of the R7RS-small modules, I would advise not getting
hung up on them.  They exist primarily to make things optional for truly
small R7RS-small implementations.  For example, the R5RS numeric tower
makes inexact numbers optional, even though only subminimal and blatantly
non-confirming Schemes (SigScheme, Mini-Scheme, Oaklisp, Owl Lisp in my
test suite) actually omit them.

So in practice (scheme inexact) could have been folded into (scheme base).
It isn't, because R7RS-small is not entirely about practice, but also about
extending downward the range of what counts as a conformant Scheme, say one
that compiles code to run on a microcontroller with no hardware floating
point.  (Similarly with the (scheme case-lambda) module, which is there
because Alex Shinn, who hates the case-lambda macro, insisted on it.)

Again, we could put delay-force, promise? and make-promise into
> (chicken base) _and_ make an aliasing module (chicken lazy)
> that has both the extended and r5rs procedures, but that seems
> awkward and annoying when you import both; you'd get constant
> warnings about re-importing identifiers.


I would not expect a warning about importing the same binding of an
identifier through more than one path: if you define a module foo that
re-exports identifiers from the base module, and then write bar importing
both the base module and foo, you should not (and do not, in Chicken or
Chibi) get a warning.


> OTOH, putting it just
> under (chicken base) might result in the aforementioned confusion
> for people familiar with r7rs.
>

I at least would expect (chicken base) to be a base module incorporating at
least the intersection of (scheme base) and (scheme r5rs), given that
Chicken is R5RS-based.  Most people add an import when they get (or know
they will get) an undefined-variable error, and Chibi's advanced REPL
("chibi-scheme -R") will helpfully search the library for a module that
defines such a variable.

Tl;dr:  merge these small modules into (chicken base).

-- 
John Cowan  http://vrici.lojban.org/~cowanco...@ccil.org
Principles.  You can't say A is made of B or vice versa.
All mass is interaction.  --Richard Feynman
___
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers


Re: [Chicken-hackers] [PATCH] Move around {rename, delete}-file and a question about module for inexact

2017-09-13 Thread Evan Hanson

Hi Peter,

On 2017-09-10 17:33, Peter Bex wrote:

Here's a straightforward patch to move those two procedures from
library.scm to file.scm.


Applied, thanks.

Evan

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