From: ludo@gnu.org (Ludovic Courtès)
To: psmith@gnu.org
Cc: guile-user@gnu.org
Subject: Re: Using guile as an extension language for GNU make
Date: Sun, 18 Sep 2011 23:28:37 +0200 [thread overview]
Message-ID: <8762kp7d6i.fsf@gnu.org> (raw)
In-Reply-To: <1316367765.28907.153.camel@homebase> (Paul Smith's message of "Sun, 18 Sep 2011 13:42:45 -0400")
Hi Paul!
Paul Smith <psmith@gnu.org> 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");
else
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".
Thanks,
Ludo’.
next prev parent reply other threads:[~2011-09-18 21:28 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-18 0:10 Using guile as an extension language for GNU make Paul Smith
2011-09-18 12:10 ` Ludovic Courtès
2011-09-18 17:21 ` Embedding vs. Extending (was: Re: Using guile as an extension language for GNU make) Paul Smith
2011-09-18 21:48 ` Embedding vs. Extending Ludovic Courtès
2011-09-18 17:42 ` Using guile as an extension language for GNU make Paul Smith
2011-09-18 21:28 ` Ludovic Courtès [this message]
2011-09-18 15:30 ` Thien-Thi Nguyen
2011-09-18 19:28 ` Paul Smith
2011-09-19 0:28 ` Thien-Thi Nguyen
2011-09-19 15:14 ` Paul Smith
2011-09-19 19:41 ` Hans Aberg
2011-09-19 21:56 ` Paul Smith
2011-09-19 22:35 ` Hans Aberg
2011-09-19 23:00 ` Hans Aberg
2011-09-21 2:42 ` Mark H Weaver
2011-09-21 8:24 ` Hans Aberg
2011-09-20 16:17 ` Thien-Thi Nguyen
2011-09-20 17:31 ` Paul Smith
2011-09-20 19:02 ` Paul Smith
2011-09-21 0:48 ` Thien-Thi Nguyen
2011-09-20 20:39 ` Thien-Thi Nguyen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8762kp7d6i.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=guile-user@gnu.org \
--cc=psmith@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).