lilypond-devel
[Top][All Lists]
Advanced

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

Re: Unsecure assoc calls


From: Michael Käppler
Subject: Re: Unsecure assoc calls
Date: Sat, 12 Sep 2009 02:27:07 +0200
User-agent: Thunderbird 2.0.0.12 (X11/20071114)


You need to amend the definition of the method in lily-guile.hh, since
it's also used directly in the C++ code, with no optional arguments:

53 SCM ly_assoc_get (SCM key, SCM alist, SCM def);
Hmm... I don't exactly understand the LY_DEFINE macro. Is it possible to implement this with overloading or have all C++ calls of ly_assoc_get to be changed to use all four parameters?
+    programming_error ("Cannot find key ~S in alist, setting to ~S.",
ly_scm2string (key), ly_scm2string (default_value));

I think what Carl is getting at here is that you can't pass these
string values using format with programming_error () without adding
the macro `(_f', but this shouldn't be used in this case since it
internationalizes the message.
programming_error (to_string ("Cannot find key %s in achain, setting to %s.", ly_scm2string (key), ly_scm2string (default_value)));

Is this basically the right way to do this?

There's a bigger problem here though, since it's not clear what the
value of the key is going to be before converting it: ly_scm2string
will only work if the scheme value is a string.  This naturally
applies to default_value too, which could conceivably be any scheme
object.
What about adding a type check to ly_scm2string and add the possibility to convert from symbols and numbers too? Isn't there a guile built-in method for converting any scheme object in a readable string?

Regards,
Michael





reply via email to

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