Re: Fetch function names & prototypes?



> Thanks.
> [Of course it's possible to construct a symbol table of functions,
> although in C++ the prototypes are found in the header files included
> by each module so there's no need. There's also an old trick: encode
> the argument types of each function as a byte string, put the byte
> string into the object file symbol table, and have the linker compare
> those byte strings and complain if they don't match. The linker doesn't
> have to understand the types, just see if they match. -John]
>

John,
The question is how do you encode the types. My intuition is that this
trick would not allow a perfect/accurate type checking. If types are
simple (say scalars), this trick would work. But if the function
arguments have complex data types, this would produce wrong type
mismatches.
S
[It's basically the same trick as C++ name mangling, represent the type
as a coded token string. If it's a complex type, the string may get long
but that's not a problem. I first saw this in the Dartmouth PL/I compiler
circa 1976, and it worked well. -John]

.



Relevant Pages

  • A neat trick to serialize arrays and hashes
    ... who thinks that my trick is "obvious to everyone but inexperienced ... hashes -- that is, it can pack and unpack arrays and hashes to and ... I might want to serialize @a into a string for the purpose of storing ... array into a string like so: ...
    (comp.lang.perl.misc)
  • Re: Efficient use of results of [binary scan]
    ... And memory allocation is *definitely* comparatively slow ... The same trick is ... naif solution, for my 100K string. ... DOULOS - Developing Design Know-how ...
    (comp.lang.tcl)
  • A C++ Whishlist
    ... Now I have come to really like Java Strings. ... a String is a String is a String. ... I believe header files are nothing but a nuisance. ... or declare it to be thrown in the function declaration. ...
    (comp.lang.cpp)
  • Re: Concatenation
    ... You can use a nifty little trick here which utilises the difference between ... "some string" + Null results in Null ...
    (microsoft.public.access.queries)
  • Re: Newbie: Convert String to Symbol?
    ... But I'm missing the conversion from string to symbol! ... (defmacro defop (symbol function) ... this "trick" is very nice when mapping assembler ...
    (comp.lang.lisp)