Noah Lavine | 23 May 04:04
Picon

Error in wip-rtl

Hello,

I tried to build the latest wip-rtl today, and hit an error that I
don't know how to debug. First, when the build gets to "GEN
guile-procedures.texi", I get a segmentation fault.

I tried to debug it by doing meta/gdb-uninstalled-guile. When I did
that, Guile made it to a command prompt, but when I try to evaluate
any sort of expression, even #t, I got "ERROR: unbound variable:
compile".

What might make that happen?

Thanks,
Noah

Ken Raeburn | 21 May 07:45

a few proposed patches

After reading the "dynamic ffi and C struct" thread this weekend, I started thinking, "I wonder if that's
really done so as to handle X and Y and Z, and if we're actually testing it well enough", and got the urge to do
another Mac build, which I hadn't done in a while.  After installing libgc 7.2 to get around flaky failures,
and fighting with the build system a bit (I have gmp installed via Macports, and that tree also has libgc
7.1…), and waiting hours for builds to finish and looking into why, I have a few patches to propose.  I've
uploaded them to the branch wip-raeburn-misc for review, since I'm not sure you'll want to address the
issues the same way.

* Eliminate use of GC_PTR.  Looks like it's a holdover from earlier versions of libgc.  Some versions don't
define it, so we do.  Apparently the 7.2 release defines it, too, which resulted in bug #11500.  It turns out,
too, that some of the casts weren't quite right (casting to GC_PTR when GC_PTR* was needed), and only
worked because GC_PTR is void* and thus can be converted to the correct type; I've tried to fix up those
cases.  The change discards some minor abstraction of the pointer interface to libgc, but I don't think we
really need an abstract name for void* anyways.

* Don't use addresses of code labels with LLVM, even if the compiler supports them.  At least with the version
of LLVM GCC on my Mac ("gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)"), the
performance seems to be quite poor; "guild compile" was showing about a 4x penalty in CPU time.  (For
psyntax-pp.go, it was 10 minutes of CPU time vs 46 minutes.)  Later/future versions may do better, so we can
update it with version-number checks, unless we want to build performance tests into the configure
script, which doesn't sound like a great idea to me.  Related to this, I made two more changes: Always define
statement labels in the VM code anyway, because vm-i-scheme.c uses some of them unconditionally (which
makes me wonder if any non-GCC configs are getting tested); and report the time taken for each "guild
compile" command during the build.

* Require libgc 7.2 or better.  Too often the fix to flaky problems seems to be "try updating to the latest
libgc and see if that fixes it", so let's just require it.  Or is 7.1 really *that* consistently reliable for
our use cases on some platforms?  I decided to go with a test in the C code because I was having problems with
include directory ordering for a while on my system, with both 7.1 and 7.2 installed.  A configure-time
check would work fine in addition, but the C check takes effect after the various include directories for
(Continue reading)

Picon

problems evaluating code depending on version

hi,

I'm trying to use this as a way to defined different versions of the code depending on the
guile-version. So here it is,



(eval-when (compile load eval)
  (define (ver)
    (let ((v (version)))
      (cond
       ((string-match "^2.0" v)
        'v2.0)
       ((string-match "^2.1" v)
        'v2.1)
       (else #f)))))

(define-syntax guile-stuff
  (lambda (x)
    (syntax-case x ()
      (_
       (let ((q (ver)))
         (cond
          ((eq? q 'v2.0)
           #'(begin 1))
          ((eq? q 'v2.1)
           #'(begin
               (define-syntax-rule (fluid-let-syntax . l)
                 (syntax-parametrize . l))
               (export fluid-let-syntax)))
          (else (error "not supported version"))))))))

(guile-stuff)

This does not work in master (v2.1) why?
/Stefan

Picon

bug in syntax-case in master

I'm trying to port syntax-parse to master. And get into the following trubble


(syntax-case x (integrate) ((integrate a b) ...))
fails, but

(syntax-case x (integrate) ((_ a b) ...))
does not fail


looking at the code for syntax-case I would expect that the datum integrate is
match against and not using syntax any syntactic information.

In psyntax.scm around 2419 we have,
((bound-id-member? p keys)
 (values (vector 'free-id p) ids))

keys are the fixed datums, and

(define bound-id-member?
      (lambda (x list)
        (and (not (null? list))
             (or (bound-id=? x (car list))
                 (bound-id-member? x (cdr list))))))

e.g. no comparisons of the datum.

Is this correct! I do understand that this can be a feature but is this expected?
In syntax parse both options are possible.

/Regards
Stefan





Mark H Weaver | 15 May 17:46

Re: Making every goops object applicable

Krister Svanlund <krister.svanlund <at> gmail.com> writes:
> For example an instance of a class inheriting a class that inherits
> <applicable-struct> that defines 'procedure is not applicable.

Looking at the code, it is clear that in order for a GOOPS instance to
be applicable, it is not enough for <applicable-struct> to be a
superclass.  It is also necessary for the _metaclass_ of its class to
have the SCM_VTABLE_FLAG_APPLICABLE_VTABLE bit set.

One such metaclass is already built-in: <applicable-struct-class>, which
is the metaclass for <applicable-struct>, but if you'd like to define
your own metaclass for applicable objects, you can set the bit manually
on the metaclass as described by Ludovic.

However, keep in mind that the presence of that bit in the metaclass
indicates that the first slot of all instances _must_ be the procedure
slot.

     Mark

Krister Svanlund | 15 May 02:46
Picon
Gravatar

Fwd: Making every goops object applicable



---------- Forwarded message ----------
From: Krister Svanlund <krister.svanlund <at> gmail.com>
Date: Tue, May 15, 2012 at 2:45 AM
Subject: Re: Making every goops object applicable
To: Mark H Weaver <mhw <at> netris.org>


On Tue, May 15, 2012 at 12:16 AM, Mark H Weaver <mhw <at> netris.org> wrote:
Krister Svanlund <krister.svanlund <at> gmail.com> writes:
> In our work to look into how Python 3 could be implemented for Guile
> we have figured out that the only way to make a goops object
> applicable is to have it inherit <applicable-struct>. This does not
> always work the way it could be expected, for example when inheriting
> from several classes.

Can you elaborate on what doesn't work as expected?

For example an instance of a class inheriting a class that inherits <applicable-struct> that defines 'procedure is not applicable.
 

> Apparently this works by some flag being set by
> <applicable-strukt> in libguile for the object and that flag is
> checked during application, calling the 'procedure slot if it's set
> with some optimization assuming that 'procedure is the first slot.
> Is this correct and if so, is there any particular reasoning behind
> this rather than just having all classes that has the slot 'procedure
> be applicable?

I see at least two problems with your suggestion: (1) it would be very
slow to search the list of slots for a slot named 'procedure' on every
application.  (2) a user might create a class with a slot named
'procedure' without intending that the slot should be used in this way.
 
(1) Given that slots aren't dynamic at runtime (as they are in Python for example) and there is already some magic being done by <applicable-struct> I have a hard time seeing how looking up a slot for application can't be done in almost constant time (one look-up and then storing a pointer to the position of the slot for future applications) and only a tiny bit slower than the current implementation. And after all, Guile is, judging by it's documentation, focused on being an extension language where the heavy lifting is supposed to be done in C code.
(2) This I'm not entirely sure how to fix but I have the impression that this could be done analogous to the initialization method of the meta-object protocol, but I assume this could require some severe internal changes and in fact slow down applications in general in Guile. My thought is that you simply have a metaclass that has a method ('apply or similar) that specifies what will happen if an instance of any of it's classes is being used as a function.

I'm mostly interested in getting all possible input about how good/bad of an idea this is so please prove (in the looses sense of the word) that I'm wrong. When I have some free time this summer I will probably make an attempt at doing this anyhow, I just want to know what I'm getting myself into.

Yours,
Krister Svanlund

Picon

terribly complex syntax objects in syntax parse

Hi,

syntax-parse is kind of heavy right now. The parser function produced are huge and the main reason
is that the stored syntax objects are enormous. I know that Mark Weaver had done something to make
these creatures less fatty. The question is if there is anything a guile user can do?

Regards
Stefan

Picon

how to implement mutual recursive parsers in syntax-parse

I do have a cludgy fix for this but are in search for a better solution.

consider the problem:

(define-syntax-class a (pattern (1 x:b)) (pattern ()))
(define-syntax-class b (pattern (2 x:a)) (pattern ()))

the syntax class definitions above would expand to something like

(begin
   (define parser-a code-a ...)
   (define-syntax a spec-a))

(begin
   (define parser-b code-b ...)
   (define-syntax b spec-b))

In racket they manage to evaluate the define-syntax forms before the define-forms cause in the expansion
of code-a amd code-b they need the spec's spec-a and spec-b.

Do you have any ideas how solve this. I do have a fix for problem but it is not easy to use.

/Stefan

Krister Svanlund | 14 May 19:24
Picon
Gravatar

Making every goops object applicable

In our work to look into how Python 3 could be implemented for Guile we have figured out that the only way to make a goops object applicable is to have it inherit <applicable-struct>. This does not always work the way it could be expected, for example when inheriting from several classes. Apparently this works by some flag being set by <applicable-strukt> in libguile for the object and that flag is checked during application, calling the 'procedure slot if it's set with some optimization assuming that 'procedure is the first slot.
Is this correct and if so, is there any particular reasoning behind this rather than just having all classes that has the slot 'procedure be applicable?

Yours,
Krister Svanlund

Nala Ginrut | 12 May 14:30
Picon
Gravatar

[Proposal] Why not add a "shell" procedure?

hi folks!
Sometimes we need to run shell script and get the result as string type.
Say, in Ruby:
irb: `ls`
==> "ice-9\nlanguage\nMakefile.am\nMakefile.am~\nMakefile.in\noop\nrnrs\nrnrs.scm\nscripts\nsrfi\nstatprof.scm\nsxml\nsystem\ntexinfo\ntexinfo.scm\nweb\n"

* Note: "system" lib function is useless for this, because "system"
can't return the result as string, but just the retval.

This feature is very easy to implement in Guile, but I recommend to
add a global env-var %current-shell to point any shell-interpreter,
like csh/bash/sh/..., or modify it as user wish.
The "shell" implementation maybe like this:
-------------code----------------
(define %current-shell (getenv "SHELL"))
(use-modules (ice-9 popen) (rnrs io ports))
(define shell
   (lambda (cmd)
       (let ((str (string-append %current-shell " -c " cmd)))
          (get-string-all (open-pipe str OPEN_READ)))))
-------------end----------------

and use it like regular shell:
(shell "sed -i \"s:guile/Guile/g" somefile")

Moreover, we can implement "pwd" with this "shell" easily:
----------code----------
(use-module (ice-9 rdelim))
(define (pwd)
  (call-with-input-string (shell "pwd")
                                     (lambda (port) (read-line port))))
-----------end-----------

(pwd)
==> "/home/nalaginrut/Project/gnulib-20100109+stable"

Any comment?

Sjoerd van Leent | 11 May 21:16
Picon

Wish List

Hi all,

As I have been playing around with the sources of Guile, I looked at
the bug section on Savannah. I couldn't see much bugs and even less
bugs which are not pending already. Can anyone hint to some things
that are easy enough to pick up so I can start contributing something
sensible?

Regards,
Sjoerd


Gmane