Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: "subexpression" |
| Date | 2015-11-27 20:16 -0500 |
| Organization | Self |
| Message-ID | <56590074.2060302@verizon.net> (permalink) |
| References | <subexpression-20151128015242@ram.dialup.fu-berlin.de> |
On 11/27/2015 08:02 PM, Stefan Ram wrote: > C uses the term »subexpression«, but does not define it. > > It is not easy to define »subexpression« on an elementary level. > > For example, in the web, one can find: > > »A subexpression is a part of an expression that is by > itself a correct expression.« > > By this, »2/3« would be a subexpression of »1/2/3«, but I > don't want this to be true. > > In the web, one can also find: > > »a subexpression is a part of an expression that > corresponds to a subtree in the parse tree«. > > That's better! So, »2/3« is /no/ subexpression in »1/2/3«, > because »1/2/3« is parsed as »(1/2)/3«. > > But can we explain »subexpression« to beginners who do > not know what a »parse tree« is? > > My first attempt was: »A subexpression is a part of a larger > expression that is an expression and can be replaced by its > value in the larger expression without changing the value of > the larger expression.« > > But by this definition, in »1/1/1«, the right »1/1« would be > a subexpression, because replacing it by its value does not > change the value of the full expression. So my first attempt > does not have all the desired properties. A sub-expression of an expression is either one of it's own direct operands, or recursively, one of it's operand's sub-expressions. I don't claim that definition to be authoritative, but I think it expresses correctly my understanding of the term, and I don't think it conflicts with anything the standard says about sub-expressions.
Back to comp.lang.c | Previous | Next — Next in thread | Find similar | Unroll thread
Re: "subexpression" James Kuyper <jameskuyper@verizon.net> - 2015-11-27 20:16 -0500
Re: "subexpression" Keith Thompson <kst-u@mib.org> - 2015-11-27 19:42 -0800
Re: "subexpression" Tim Rentsch <txr@alumni.caltech.edu> - 2015-11-28 06:33 -0800
Re: "subexpression" James Kuyper <jameskuyper@verizon.net> - 2015-11-28 10:21 -0500
csiph-web