octave-maintainers
[Top][All Lists]
Advanced

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

Re: Implementing show_source function


From: Jordi Gutiérrez Hermoso
Subject: Re: Implementing show_source function
Date: Mon, 1 Aug 2011 11:53:48 -0500

2011/5/4 Jordi Gutiérrez Hermoso <address@hidden>:
> Right now that I'm starting to work with Sage at the Sage Days 30
> workshop, I've found that it has a nice feature. If you type
> "edit(foo)" where foo is any symbol that Python knows about, Sage
> will open an editor at the file and line number where this Python
> object is defined. So it's very convenient for inspecting the
> source. And it seems to be working, observe how many non-expert
> programmers but able mathematicians are contributing to Sage.
>
> Octave has a few mechanisms sort of in place to do this partially,
> like the edit function and the help function, but they don't work
> for compiled code (I don't know if Sage has solved this problem for
> compiled code either). I can see how to do this for m-scripts, but
> how could something comparable be done for compiled-in functions?
> I'm thinking it should be possible to modify the DEFUN family of
> macros to include __LINE__ and __FILE__ so that this information is
> available to the interpreter. Would this be feasible? I haven't
> really tried to untangle the magic behind DEFUN.

I'm thinking more seriously about this, but in order to make it really
useful, I think I need to make a small modification to the build
system.

It would be most useful if you could produce a pathname relative to
Octave's root source tree, but CPP doesn't offer such a macro. You can
create one, however, when invoking g++ with -D and using some shell
command to figure out the proper macro, as suggested in this thread:

     
http://stackoverflow.com/questions/2449576/c-c-full-file-path-in-assert-macro

Before I proceed, I just want to make sure this isn't a completely
stupid idea. (It's also a nice little exercise to at least prod the
build system and see if I can make it do what I want.)

- Jordi G. H.


reply via email to

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