Re: basic question about runtime query parsing

Laurence Finston <lfinsto1@gwdg.de>
22 Jul 2005 20:15:15 -0400

          From comp.compilers

Related articles
basic question about runtime query parsing shahbazc@gmail.com (falcon) (2005-07-11)
Re: basic question about runtime query parsing antounk@comcast.net (Antoun Kanawati) (2005-07-12)
Re: basic question about runtime query parsing skandgoe@gwdg.de (Skandinavisches Seminar) (2005-07-12)
Re: basic question about runtime query parsing wyrmwif@tsoft.org (SM Ryan) (2005-07-12)
Re: basic question about runtime query parsing gneuner2@comcast.net (George Neuner) (2005-07-12)
Re: basic question about runtime query parsing kers@hpl.hp.com (Chris Dollin) (2005-07-17)
Re: basic question about runtime query parsing lfinsto1@gwdg.de (Laurence Finston) (2005-07-22)
Re: basic question about runtime query parsing shahbazc@gmail.com (falcon) (2005-07-22)
Re: basic question about runtime query parsing kers@hpl.hp.com (Chris Dollin) (2005-07-26)
Re: basic question about runtime query parsing lfinsto1@gwdg.de (Laurence Finston) (2005-07-28)
Re: basic question about runtime query parsing kers@hpl.hp.com (Chris Dollin) (2005-07-31)
Re: basic question about runtime query parsing skandgoe@gwdg.de (Skandinavisches Seminar) (2005-08-01)
Re: basic question about runtime query parsing marcov@stack.nl (Marco van de Voort) (2005-08-03)
[1 later articles]
| List of all articles for this month |

From: Laurence Finston <lfinsto1@gwdg.de>
Newsgroups: comp.compilers
Date: 22 Jul 2005 20:15:15 -0400
Organization: GWDG, Goettingen
References: 05-07-045 05-07-056 05-07-066
Keywords: code
Posted-Date: 22 Jul 2005 20:15:15 EDT

On Sun, 17 Jul 2005, Chris Dollin wrote:


> Skandinavisches Seminar wrote:
>
>> I don't believe that compilation "on the fly" is possible with C.
>
> It's certainly possible: it's just not *portable*.


[...]


> Not true; you can generate a dynamic-linked library and dlopen it.


Thanks for the information. I'll have to look up 'dlopen'. However,
even if it's possible, I think there's probably an easier and safer
solution for most programming tasks. I don't dispute that it could be
useful for some special ones.


It seems to me that such a program would be difficult to debug, since
you wouldn't just have to worry about errors in the program itself,
but also compilation, linking, and run-time errors in the generated
code, all of which would occur during the "outer" program's run-time.
Depending on the possible complexity of the generated code, I think
that it could easily become practically impossible to test. I believe
that determining the number of possible cases would involve
combinations, and this implies that the number of possible outputs
increases so fast with increasing inputs that the number of cases
quickly becomes unmanageable. And if, as you say, it wouldn't be
portable anyway, what would be the point?


> So, not only is it possible: it's been done, and yonks ago.


I don't think it signifies that it was done a long time ago. People
used to do lots of tricky things to cope with the limitations of the
computers of the time. Self-modifying code, for example. I don't
think anyone thinks this is a good idea anymore, unless it's
absolutely necessary. I always try to solve problems in the simplest
way possible: "as little as possible, as much as necessary".


I now see that I misunderstood the original question. One easy way of
doing what falcon describes would be to use a hash table with elements
containing a linked list like this:


struct Table_Node {
          unsigned short type;
          void* object;
          struct Table_Node* next; };


The members of the hash table would look like this:


struct Hash_Node {
          char[MAX_NAME] name;
          struct Table_Node* table_node;
          struct Hash_Node* up;
          struct Hash_Node* left;
          struct Hash_Node* right; };




Memory for 'Hash_Nodes', the 'Table_Nodes', and the latter's 'object'
elements would be allocated dynamically. This approach requires no
run-time type information (RTTI).


Laurence Finston


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.