General purpose Expression Parser

Discussion in 'C Programming' started by Dexter, Mar 20, 2008.

  1. Dexter

    Dexter Guest

    Dexter, Mar 20, 2008
    #1
    1. Advertising

  2. Re: [OT] General purpose Expression Parser

    Dexter wrote:
    > This Java based utility may be invoked from Java code to parse
    > mathematical expressions. It is useful for programmers developing
    > calculators, graphing utilities or other math related programs.
    >
    > Download for free at http://www.thinkanddone.com/prog/java/parser.html
    >
    > If the above link does not work try http://www.britishcomputercolleges.com/prog/java/parser2.html



    An interview of the inventor of C++ templates, Alexander Stepanov, where
    it mentions Java:

    http://www.stlport.org/resources/StepanovUSA.html



    An interesting link I came across the web:

    http://icl.pku.edu.cn/bswen/_old_stuff/cpp/java-to-cpp.html
    Ioannis Vranos, Mar 20, 2008
    #2
    1. Advertising

  3. Dexter

    Ian Collins Guest

    Re: [OT] General purpose Expression Parser

    Ioannis Vranos wrote:
    > Dexter wrote:
    >> This Java based utility may be invoked from Java code to parse
    >> mathematical expressions. It is useful for programmers developing
    >> calculators, graphing utilities or other math related programs.
    >>
    >> Download for free at http://www.thinkanddone.com/prog/java/parser.html
    >>
    >> If the above link does not work try
    >> http://www.britishcomputercolleges.com/prog/java/parser2.html

    >
    >
    > An interview of the inventor of C++ templates, Alexander Stepanov, where
    > it mentions Java:
    >

    <EvenMoreOT>He didn't invent templates, he was the authour of the
    Standard Template Library</EvenMoreOT>

    What has this to do with C anyway?

    --
    Ian Collins.
    Ian Collins, Mar 20, 2008
    #3
  4. Re: [OT] General purpose Expression Parser

    Ian Collins wrote:
    > Ioannis Vranos wrote:
    >> Dexter wrote:
    >>> This Java based utility may be invoked from Java code to parse
    >>> mathematical expressions. It is useful for programmers developing
    >>> calculators, graphing utilities or other math related programs.
    >>>
    >>> Download for free at http://www.thinkanddone.com/prog/java/parser.html
    >>>
    >>> If the above link does not work try
    >>> http://www.britishcomputercolleges.com/prog/java/parser2.html

    >>
    >> An interview of the inventor of C++ templates, Alexander Stepanov, where
    >> it mentions Java:
    >>

    > <EvenMoreOT>He didn't invent templates, he was the authour of the
    > Standard Template Library</EvenMoreOT>



    AFAIK he invented templates.

    > What has this to do with C anyway?



    Nothing right now. However I think template functions and structs could
    be introduced in C.
    Ioannis Vranos, Mar 20, 2008
    #4
  5. Dexter

    Ben Pfaff Guest

    Re: [OT] General purpose Expression Parser

    Ioannis Vranos <> writes:

    > I think template functions and structs could be introduced in
    > C.


    You can already use them in C++. There is no need for them in C.
    --
    Ben Pfaff
    http://benpfaff.org
    Ben Pfaff, Mar 20, 2008
    #5
  6. Re: [OT] General purpose Expression Parser

    Ben Pfaff wrote:
    > Ioannis Vranos <> writes:
    >
    >> I think template functions and structs could be introduced in
    >> C.

    >
    > You can already use them in C++. There is no need for them in C.



    So, whatever we can use in C++ needs not be provided in C. In other
    words you are saying that C is obsolete.

    Templates can replace elegantly C's generic programming which is now
    done by using void pointers and indentifiers.
    Ioannis Vranos, Mar 21, 2008
    #6
  7. Dexter

    Ian Collins Guest

    Re: [OT] General purpose Expression Parser

    Ioannis Vranos wrote:
    > Ben Pfaff wrote:
    >> Ioannis Vranos <> writes:
    >>
    >>> I think template functions and structs could be introduced in
    >>> C.

    >>
    >> You can already use them in C++. There is no need for them in C.

    >
    >
    > So, whatever we can use in C++ needs not be provided in C. In other
    > words you are saying that C is obsolete.
    >
    > Templates can replace elegantly C's generic programming which is now
    > done by using void pointers and indentifiers.


    King 'ell not again!

    You could say that any C++ feature would enhance C, when all you would
    end up with is an early C++ compiler and you know where they ended up.
    Templates lead to function over loading which leads to....

    We all have our pet C enhancements, which can be suggested on comp.std.c.

    --
    Ian Collins.
    Ian Collins, Mar 21, 2008
    #7
  8. Re: [OT] General purpose Expression Parser

    In article <fruuv3$nl4$>,
    Ioannis Vranos <> wrote:

    >>> I think template functions and structs could be introduced in
    >>> C.


    >> You can already use them in C++. There is no need for them in C.


    >So, whatever we can use in C++ needs not be provided in C. In other
    >words you are saying that C is obsolete.


    Not at all. He's saying there's no point making C be the same
    as C++. If you want C++, you know where to find it.

    Of course, both positions are too extreme.

    -- Richard
    --
    :wq
    Richard Tobin, Mar 21, 2008
    #8
  9. Re: [OT] General purpose Expression Parser

    Ian Collins wrote:
    > Ioannis Vranos wrote:
    >> Ben Pfaff wrote:
    >>> Ioannis Vranos <> writes:
    >>>
    >>>> I think template functions and structs could be introduced in
    >>>> C.
    >>> You can already use them in C++. There is no need for them in C.

    >>
    >> So, whatever we can use in C++ needs not be provided in C. In other
    >> words you are saying that C is obsolete.
    >>
    >> Templates can replace elegantly C's generic programming which is now
    >> done by using void pointers and indentifiers.

    >
    > King 'ell not again!
    >
    > You could say that any C++ feature would enhance C, when all you would
    > end up with is an early C++ compiler and you know where they ended up.
    > Templates lead to function over loading which leads to....
    >
    > We all have our pet C enhancements, which can be suggested on comp.std.c.



    Actually making "versions" inside a generic C function which uses void
    pointers, for every type it can accept, I think is usually more bloated
    code than providing a simple template function. Also the template one is
    faster since it has not those conditional-specialisations.

    A C programmer, as a C++ programmer does now, could control his code and
    not let it become bloated.


    In general, templates are more elegant (simpler) and more efficient than
    bloated generic functions using void pointers and conditional statements
    to determine the type(s) of object(s) passed.

    Also they can replace macros in 99% of the times leading to more robust
    code.


    I think C can borrow these things from C++, as it has borrowed things
    from C++ in the past (function prototypes etc).
    Ioannis Vranos, Mar 21, 2008
    #9
  10. Dexter

    CBFalconer Guest

    Re: [OT] General purpose Expression Parser

    Ioannis Vranos wrote:
    > Ben Pfaff wrote:
    >> Ioannis Vranos <> writes:
    >>
    >>> I think template functions and structs could be introduced in
    >>> C.

    >>
    >> You can already use them in C++. There is no need for them in C.

    >
    > So, whatever we can use in C++ needs not be provided in C. In
    > other words you are saying that C is obsolete.


    Don't be silly. You select a language to suit the job. If you
    really need template functions use C++ or better languages (Ada,
    for example). You probably don't need them.

    --
    [mail]: Chuck F (cbfalconer at maineline dot net)
    [page]: <http://cbfalconer.home.att.net>
    Try the download section.



    --
    Posted via a free Usenet account from http://www.teranews.com
    CBFalconer, Mar 21, 2008
    #10
  11. Dexter

    CBFalconer Guest

    Re: [OT] General purpose Expression Parser

    Ioannis Vranos wrote:
    > Ian Collins wrote:
    >

    .... snip ...
    >>
    >> We all have our pet C enhancements, which can be suggested on
    >> comp.std.c.

    >
    > Actually making "versions" inside a generic C function which uses
    > void pointers, for every type it can accept, I think is usually
    > more bloated code than providing a simple template function. Also
    > the template one is faster since it has not those conditional-
    > specialisations.


    You should take this to comp.compilers.lcc and join with Jacob
    Navia. There it can be on-topic, and Jacob will agree with you.
    Here it is off-topic, and virtually noone will agree with you.

    --
    [mail]: Chuck F (cbfalconer at maineline dot net)
    [page]: <http://cbfalconer.home.att.net>
    Try the download section.



    --
    Posted via a free Usenet account from http://www.teranews.com
    CBFalconer, Mar 21, 2008
    #11
  12. Dexter

    santosh Guest

    Re: [OT] General purpose Expression Parser

    CBFalconer wrote:

    > Ioannis Vranos wrote:
    >> Ian Collins wrote:
    >>

    > ... snip ...
    >>>
    >>> We all have our pet C enhancements, which can be suggested on
    >>> comp.std.c.

    >>
    >> Actually making "versions" inside a generic C function which uses
    >> void pointers, for every type it can accept, I think is usually
    >> more bloated code than providing a simple template function. Also
    >> the template one is faster since it has not those conditional-
    >> specialisations.

    >
    > You should take this to comp.compilers.lcc and join with Jacob
    > Navia. There it can be on-topic, and Jacob will agree with you.
    > Here it is off-topic, and virtually noone will agree with you.


    He *was* talking about standard C code, essentially saying that
    functions accepting void * arguments and including separate code to
    deal with all supported argument types is actually more bloated and
    slow than code derived through some form of generics.

    In pure C the closest one can come to type generic source code is
    through the macro processor.
    santosh, Mar 21, 2008
    #12
  13. Re: [OT] General purpose Expression Parser

    Ioannis Vranos said:
    > Ben Pfaff wrote:
    >> Ioannis Vranos <> writes:
    >>
    >>> I think template functions and structs could be introduced in
    >>> C.

    >>
    >> You can already use them in C++. There is no need for them in C.

    >
    > So, whatever we can use in C++ needs not be provided in C. In other
    > words you are saying that C is obsolete.


    CUSTOMER: "I'd like a knife and fork, please."
    WAITER: "Here you are, sir."
    CUSTOMER: "Wait a moment - this fork has no sharp edge."
    WAITER: "That's right."
    CUSTOMER: "But this knife has a lovely edge on it. Why can't the fork be
    like that?"
    WAITER: "Because it's a fork."
    CUSTOMER: "This knife has serrations along the blade to improve its grip
    during the cut. Why can't the fork have serrations?"
    WAITER: "Because it's a fork. If you want to cut, use the knife."
    CUSTOMER: "So what you're saying is that the fork is useless? I don't need
    it?"
    WAITER: "No, what I'm saying is that I don't get paid enough to deal with
    people like you."

    --
    Richard Heathfield <http://www.cpax.org.uk>
    Email: -http://www. +rjh@
    Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
    "Usenet is a strange place" - dmr 29 July 1999
    Richard Heathfield, Mar 21, 2008
    #13
  14. Dexter

    Ian Collins Guest

    Re: [OT] General purpose Expression Parser

    CBFalconer wrote:
    > Ioannis Vranos wrote:
    >> Ben Pfaff wrote:
    >>> Ioannis Vranos <> writes:
    >>>
    >>>> I think template functions and structs could be introduced in
    >>>> C.
    >>> You can already use them in C++. There is no need for them in C.

    >> So, whatever we can use in C++ needs not be provided in C. In
    >> other words you are saying that C is obsolete.

    >
    > Don't be silly. You select a language to suit the job. If you
    > really need template functions use C++ or better languages (Ada,
    > for example). You probably don't need them.
    >

    How do you know what others need? If nobody needed function templates,
    C++ wouldn't have a standard library built around them.

    --
    Ian Collins.
    Ian Collins, Mar 21, 2008
    #14
  15. Re: [OT] General purpose Expression Parser

    Ian Collins said:

    > CBFalconer wrote:
    >> Ioannis Vranos wrote:
    >>> Ben Pfaff wrote:
    >>>> Ioannis Vranos <> writes:
    >>>>
    >>>>> I think template functions and structs could be introduced in
    >>>>> C.
    >>>> You can already use them in C++. There is no need for them in C.
    >>> So, whatever we can use in C++ needs not be provided in C. In
    >>> other words you are saying that C is obsolete.

    >>
    >> Don't be silly. You select a language to suit the job. If you
    >> really need template functions use C++ or better languages (Ada,
    >> for example). You probably don't need them.
    >>

    > How do you know what others need? If nobody needed function templates,
    > C++ wouldn't have a standard library built around them.


    Nobody needs function templates. All you need is a big old array, ++p, --p,
    ++*p, --*p, putchar(*p), *p = getchar(), jump from HERE to THERE if *p is
    0, and jump back from THERE to HERE. And you probably don't *need* all of
    those.

    --
    Richard Heathfield <http://www.cpax.org.uk>
    Email: -http://www. +rjh@
    Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
    "Usenet is a strange place" - dmr 29 July 1999
    Richard Heathfield, Mar 21, 2008
    #15
  16. Dexter

    Ian Collins Guest

    Re: [OT] General purpose Expression Parser

    Richard Heathfield wrote:
    > Ian Collins said:
    >
    >> CBFalconer wrote:
    >>> Ioannis Vranos wrote:
    >>>> Ben Pfaff wrote:
    >>>>> Ioannis Vranos <> writes:
    >>>>>
    >>>>>> I think template functions and structs could be introduced in
    >>>>>> C.
    >>>>> You can already use them in C++. There is no need for them in C.
    >>>> So, whatever we can use in C++ needs not be provided in C. In
    >>>> other words you are saying that C is obsolete.
    >>> Don't be silly. You select a language to suit the job. If you
    >>> really need template functions use C++ or better languages (Ada,
    >>> for example). You probably don't need them.
    >>>

    >> How do you know what others need? If nobody needed function templates,
    >> C++ wouldn't have a standard library built around them.

    >
    > Nobody needs function templates. All you need is a big old array, ++p, --p,
    > ++*p, --*p, putchar(*p), *p = getchar(), jump from HERE to THERE if *p is
    > 0, and jump back from THERE to HERE. And you probably don't *need* all of
    > those.
    >

    I walked into that one with my eyes open, didn't I?

    --
    Ian Collins.
    Ian Collins, Mar 21, 2008
    #16
  17. Re: [OT] General purpose Expression Parser

    Ioannis Vranos <> writes:

    > Ian Collins wrote:
    > > Ioannis Vranos wrote:
    > >> An interview of the inventor of C++ templates, Alexander Stepanov, where
    > >> it mentions Java:

    ....
    > AFAIK he invented templates.


    Whatever you mean by template, I don't think he invented them.
    - If you mean "parametric polymorphism", Strachey introduced his
    classification in 1967, when A.Stepanov was 17, and I think Strachey
    classified notions which where already existing.

    - If you mean the specific of C++ way, I suggest reading the section 4.1.2
    of http://www.research.att.com/~bs/hopl-almost-final.pdf where you'll find
    that while he was working at Bell Labs at the time when C++ template where
    designed, he failed in convincing Bjarne Stroustrup to make that mecanism
    more similar to Ada generics. BTW, it is that difference which make the STL
    so more friendly than his earlier work in Ada.

    Yours,

    --
    Jean-Marc
    Jean-Marc Bourguet, Mar 21, 2008
    #17
  18. Re: [OT] General purpose Expression Parser

    "Richard Heathfield" <> wrote in message
    news:...
    > Ioannis Vranos said:
    >> Ben Pfaff wrote:
    >>> Ioannis Vranos <> writes:
    >>>
    >>>> I think template functions and structs could be introduced in
    >>>> C.
    >>>
    >>> You can already use them in C++. There is no need for them in C.

    >>
    >> So, whatever we can use in C++ needs not be provided in C. In other
    >> words you are saying that C is obsolete.

    >
    > CUSTOMER: "I'd like a knife and fork, please."
    > WAITER: "Here you are, sir."
    > CUSTOMER: "Wait a moment - this fork has no sharp edge."
    > WAITER: "That's right."
    > CUSTOMER: "But this knife has a lovely edge on it. Why can't the fork be
    > like that?"
    > WAITER: "Because it's a fork."
    > CUSTOMER: "This knife has serrations along the blade to improve its grip
    > during the cut. Why can't the fork have serrations?"
    > WAITER: "Because it's a fork. If you want to cut, use the knife."
    > CUSTOMER: "So what you're saying is that the fork is useless? I don't need
    > it?"
    > WAITER: "No, what I'm saying is that I don't get paid enough to deal with
    > people like you."


    LOL. :^D
    Chris Thomasson, Mar 21, 2008
    #18
  19. Dexter

    CBFalconer Guest

    Re: [OT] General purpose Expression Parser

    Ian Collins wrote:
    > CBFalconer wrote:
    >> Ioannis Vranos wrote:
    >>> Ben Pfaff wrote:
    >>>> Ioannis Vranos <> writes:
    >>>>
    >>>>> I think template functions and structs could be introduced in
    >>>>> C.
    >>>>
    >>>> You can already use them in C++. There is no need for them in C.
    >>>
    >>> So, whatever we can use in C++ needs not be provided in C. In
    >>> other words you are saying that C is obsolete.

    >>
    >> Don't be silly. You select a language to suit the job. If you
    >> really need template functions use C++ or better languages (Ada,
    >> for example). You probably don't need them.

    >
    > How do you know what others need? If nobody needed function
    > templates, C++ wouldn't have a standard library built around them.


    Read it again. I didn't claim to know what others need. I said
    "If you need them then ...". I said "probably don't". It is also
    a fact that they don't exist in C, and are thus off topic here.

    --
    [mail]: Chuck F (cbfalconer at maineline dot net)
    [page]: <http://cbfalconer.home.att.net>
    Try the download section.



    --
    Posted via a free Usenet account from http://www.teranews.com
    CBFalconer, Mar 21, 2008
    #19
  20. Re: [OT] General purpose Expression Parser

    CBFalconer wrote:
    >
    > You should take this to comp.compilers.lcc and join with Jacob
    > Navia. There it can be on-topic, and Jacob will agree with you.
    > Here it is off-topic, and virtually noone will agree with you.



    I suppose you know what templates are. If you do, I suppose you consider
    having complex numbers and rest of area-specific stuff built in better
    than having useful general purpose facilities built in.
    Ioannis Vranos, Mar 21, 2008
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robert Bj?rn
    Replies:
    0
    Views:
    409
    Robert Bj?rn
    Jun 1, 2004
  2. Maarten van Reeuwijk

    Looking for very simple general purpose tokenizer

    Maarten van Reeuwijk, Jan 19, 2004, in forum: Python
    Replies:
    6
    Views:
    370
  3. Ron Stephens
    Replies:
    23
    Views:
    2,775
    Ron Stephens
    Apr 12, 2004
  4. Donald Newcomb

    NEWB: General purpose list iteration?

    Donald Newcomb, Aug 12, 2005, in forum: Python
    Replies:
    4
    Views:
    302
    Donald Newcomb
    Aug 12, 2005
  5. John Machin
    Replies:
    6
    Views:
    377
    metaperl
    Aug 16, 2006
Loading...

Share This Page