[Top][All Lists]

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

Re: Unsecure assoc calls

From: Carl Sorensen
Subject: Re: Unsecure assoc calls
Date: Fri, 11 Sep 2009 18:54:55 -0600

On 9/11/09 6:27 PM, "Michael Käppler" <address@hidden> wrote:

>> 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);

Can't you just use 

  SCM ly_assoc_get (SCM key, SCM alist, SCM def,
                     SCM strict_check = SCM_BOOL_F);

in lily-guile.hh?

And with this definition, all the 3-parameter calls to ly_assoc_get will
assume that strict_check is false?

> 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.

Actually, that wasn't what I was getting at, but you got the right answer
from Neil, anyway.

> 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?

Yes, there is.  It's object->string.  See



reply via email to

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