file magic

2011-11-01 Thread dsmich
Greetings Guilers,

The other day I happened to run the file command on some .go files, and they 
show up as the rather unhelpful "data".  So I added some bits to my /etc/magic 
file:

0   string   GOOF   Guile Object
>8  string   LE little endian
>8  string   BE big endian
>11 byte 0x34   32bit
>11 byte 0x38   64bit
>13 regex[0-9.]+v%s


Much nicer.

I'm on a Debian system, and /etc/magic is there for the editing of local 
customizations like this.  Not sure if that's possible on other systems.  Sure 
would be nice if this could be updated at install time.

-Dale




Accessing multiple values from C

2011-11-01 Thread Julian Graham
Hey all,

I was playing around with some C code that uses the new R6RS
bytevector ports, and I noticed that there doesn't seem to be an easy
way (a la `let-values' or `receive') to access multiple return values
from C.  I've resorted to doing:

  scm_struct_ref (foo, SCM_INUM0);

...which is almost certainly not future-proof.  All I want to do is
access these values as a pair or list.  Is there a Right Way to do
that?


Thanks,
Julian



Re: file magic

2011-11-01 Thread Ludovic Courtès
Hi Dale!

 skribis:

> The other day I happened to run the file command on some .go files, and they 
> show up as the rather unhelpful "data".  So I added some bits to my 
> /etc/magic file:
>
> 0   string   GOOF   Guile Object
>>8  string   LE little endian
>>8  string   BE big endian
>>11 byte 0x34   32bit
>>11 byte 0x38   64bit
>>13 regex[0-9.]+v%s

Neat!  What about submitting it upstream?  :-)

Ludo’.




Re: Accessing multiple values from C

2011-11-01 Thread Ludovic Courtès
Hi,

Julian Graham  skribis:

> I was playing around with some C code that uses the new R6RS
> bytevector ports, and I noticed that there doesn't seem to be an easy
> way (a la `let-values' or `receive') to access multiple return values
> from C.  I've resorted to doing:
>
>   scm_struct_ref (foo, SCM_INUM0);
>
> ...which is almost certainly not future-proof.  All I want to do is
> access these values as a pair or list.

Values were already structs in 1.8, so that’s OK.

Perhaps this should be documented though, and C accessors could be
provided.

> Is there a Right Way to do that?

Yes: write Scheme code!  :-)

In 1.8 multiple-values were always a struct, which had to be allocated
each time multiple values were returned.  In 2.0 it’s a struct only if
it has to cross the Scheme/C boundary–otherwise the values are stored on
the VM stack.

Thanks,
Ludo’.