[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using guile as an extension language for GNU make

From: Ludovic Courtès
Subject: Re: Using guile as an extension language for GNU make
Date: Sun, 18 Sep 2011 23:28:37 +0200
User-agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.50 (gnu/linux)

Hi Paul!

Paul Smith <address@hidden> skribis:

> On Sun, 2011-09-18 at 14:10 +0200, Ludovic Courts wrote:
>> There are two problems I can think of here:
>>   - string unquoting is actually more complex than this (recall that
>>     ‘object->string’ merely calls ‘write’):
>>   - ‘scm_c_eval_string’ can return any Scheme objects, some of which
>>     have meaningless representations as strings:
>> The latter is probably the most serious question.  I think you would
>> really want to constrain expressions passed in $(guile ...) to return
>> a string, and not any other type of objects.
>> In that case, you could solve the first problem by using (display ...)
>> instead of (write ...).
> There's no question that the string conversion is a hack: that's mainly
> why I'm asking here :-).

Heh, understood.  :-)

> I don't want to restrict it to just strings; for example I'd have to
> support numbers as well (one of GNU make's main issues right now is that
> there is no math capability whatsoever).  I'd like to be able to
> possibly convert other things like t and nil (in GNU make's terms,
> "false" is the empty string and "true" is any non-empty string).  Maybe
> there are other things as well (what about symbols like 'foobar?), I
> don't know.

OK, makes sense.  What about defining the Scheme data types that would
be acceptable to pass back at the make level?  I think you pretty much
listed them above: strings, numbers, and booleans.

In your code, you would type-check them along these lines:

  char *c str;


  if (scm_is_string (obj))
    c_str = scm_to_locale_string (obj); /* No quoting issue here. */
  else if (scm_is_number (obj))
    c_str = scm_to_locale_string (object_to_string (obj));
  else if (scm_is_false (obj))
    c_str = strdup ("#f");
  else if (scm_is_eq (obj, SCM_BOOL_T))
    c_str = strdup ("#t");
    scm_wrong_type_arg (__func__, 0, obj);

> As above, the double-quote stripping is intensely hacky :-).  I'll look
> into the concepts of display and write and see what I can figure out.
> Any suggestions or pointers to example code are welcome.

See info "(guile) Scheme Write".


reply via email to

[Prev in Thread] Current Thread [Next in Thread]