Re: A bit further toward the flamewar

2011-10-17 Thread Andy Wingo
On Fri 14 Oct 2011 18:23, Linas Vepstas  writes:

> 2) Flame-war.
>
> In the spirit of 2),

Whee!

(I generally avoid flamewars, but this one has not caught fire yet :)

> So the proposal is: (shout me down, when ready): create a new srfi,
> defining an ML-like conception of types, so that scheme functions can
> be annotated with types.

I suggest instead taking a look at Typed Racket, from the PLT folks.
They have done a lot of good thinking there.

Andy
-- 
http://wingolog.org/



Strange error from %search-load-path via include-from-path when parameter is not a literal string

2011-10-17 Thread Ian Hulin
Hi,

I'm trying to write a V2/V1 compatible function like the following:

(define (ly:include the-file)
  (if (string>? (version) "1.9.10")
  (include-from-path the-file)
  (load-from-path the-file)))

I get
ERROR in procedure %search-load-path: Wrong type to apply in position
1 (expecting string): the-file.

Bug or user error?

(include-from-path) also gives similar errors at the REPL when the
filename argument is not a literal string.

Guile Version is 2.0.2

Cheers,
Ian Hulin




Re: Strange error from %search-load-path via include-from-path when parameter is not a literal string

2011-10-17 Thread Andy Wingo
Hi,

On Mon 17 Oct 2011 20:20, Ian Hulin  writes:

> I'm trying to write a V2/V1 compatible function like the following:
>
> (define (ly:include the-file)
>   (if (string>? (version) "1.9.10")
>   (include-from-path the-file)
>   (load-from-path the-file)))
>
> I get
> ERROR in procedure %search-load-path: Wrong type to apply in position
> 1 (expecting string): the-file.
>
> Bug or user error?

User error, unfortunately.  `include' is a macro that expects a literal
string, not a procedure that expects an expression that evaluates to a
string.  For this to work, ly:include would also need to be a macro.

How about:

  (cond-expand
(guile-2
 (define-syntax ly:include
   (syntax-rules ()
 ((_ the-file) (include-from-path the-file)
(else
 (define (ly:include the-file)
   (load-from-path the-file

Assuming of course that you really need it to be ly:include.  The
portable (1.8/2.0) option is to use modules instead of load-from-path.

Regards,

Andy
-- 
http://wingolog.org/



Re: Strange error from %search-load-path via include-from-path when parameter is not a literal string

2011-10-17 Thread Mark H Weaver
Ian Hulin  writes:
> I'm trying to write a V2/V1 compatible function like the following:
>
> (define (ly:include the-file)
>   (if (string>? (version) "1.9.10")
>   (include-from-path the-file)
>   (load-from-path the-file)))

The problem is that `include' and `include-from-path' are not
procedures, but syntactic constructs that actually replace themselves
with the contents of the included file at macro-expansion time.

Among other things, this allows you to include a file into a local
lexical environment, e.g. if "foo.scm" contains "(define test 5)" then
the following procedure will return 5, and `test' will become a local
variable within `foo':

  (define (foo)
(include "foo.scm")
test)

Since `include' and `include-from-path' is performed at macro-expansion
time, obviously its parameter must be a literal string at
macro-expansion time.  Therefore, you can't use it from a procedure as
you attempted, but you could make a macro instead:

(define-syntax ly:include
   (if (string>? (version) "1.9.10")
   (syntax-rules () ((_ fn) (include-from-path fn)))
   (syntax-rules () ((_ fn) (load-from-path fn)

Best,
 Mark