guile-devel
[Top][All Lists]
Advanced

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

Re: unknown location: definition in expression context in subform optnam


From: Mark H Weaver
Subject: Re: unknown location: definition in expression context in subform optname-from of "_^"
Date: Sat, 28 Jan 2012 23:12:28 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux)

Andy Wingo <address@hidden> writes:
> On Sat 28 Jan 2012 20:47, Mark H Weaver <address@hidden> writes:
>> Andy Wingo <address@hidden> writes:
>>> Didn't we settle on eval-string, with the #:file and #:line kwargs?  See
>>> eval-string in the manual.
>>
>> I guess the code to use that from C would look something like this:
>
> It can look a little better, if you don't consider columns:

We should not design our APIs based on what suboptimal, inefficient code
would look like.  Instead, we should consider what ideal, efficient code
is needed to accomplish a given task using our APIs.  The best code will
provide the columns, and avoid the wasted effort of repeatedly interning
keywords.

Our current API encourages sloppiness by making it tedious to do the
right thing.  We provide a very convenient interface to evaluate a C
string without source information, thus encouraging coders to use that
even if source information is conveniently available to them.  It seems
to me that we should provide equally convenient means of doing the right
thing.

I propose that we add a single new function:

  SCM scm_eval_string_from_file (SCM string, SCM module, SCM file_name,
                                 long line, long column, int compile_p);

Where 'module' can be SCM_UNDEFINED, in which case 'current-module' is
used (and neither set nor restored).  This provides maximum flexibility
regarding the encodings of the strings, allows the user to cache the
file_name if desired, and yet allows most of the needless complications
to be hidden within this helper function while remaining efficient.

In short, this single function allows code to do the ideal thing
relatively painlessly.  Typical usage might be something like this:

  SCM
  my_eval (const char *string, const char *file_name,
          long line, long column)
  {
    return scm_eval_string_from_file
      (scm_from_locale_string (string), SCM_UNDEFINED,
       scm_from_locale_string (file_name), line, column, 0);
  }

What do you think?

    Mark



reply via email to

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