Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #77300 > unrolled thread
| Started by | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| First post | 2015-11-27 20:16 -0500 |
| Last post | 2015-11-28 10:21 -0500 |
| Articles | 4 — 3 participants |
Back to article view | Back to comp.lang.c
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
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
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Date | 2015-11-27 20:16 -0500 |
| Subject | Re: "subexpression" |
| Message-ID | <56590074.2060302@verizon.net> |
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.
[toc] | [next] | [standalone]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2015-11-27 19:42 -0800 |
| Message-ID | <lnr3jayel0.fsf@kst-u.example.com> |
| In reply to | #77300 |
James Kuyper <jameskuyper@verizon.net> writes:
[...]
> 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.
Is an expression a subexpression of itself? If so, we could refer to a
"proper subexpression" much as we talk about "proper subsets".
The standard's usage of the term is consistent with an expression *not*
being its own subexpression.
> 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.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
[toc] | [prev] | [next] | [standalone]
| From | Tim Rentsch <txr@alumni.caltech.edu> |
|---|---|
| Date | 2015-11-28 06:33 -0800 |
| Message-ID | <kfnpoyuxkgs.fsf@x-alumni2.alumni.caltech.edu> |
| In reply to | #77305 |
Keith Thompson <kst-u@mib.org> writes:
> James Kuyper <jameskuyper@verizon.net> writes:
> [...]
>> 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.
>
> Is an expression a subexpression of itself? If so, we could refer
> to a "proper subexpression" much as we talk about "proper subsets".
Usually the term subexpression admits the case of the entire
expression (or what the Standard calls a full expression).
When it's important to distinguish the two possibilities,
I would expect the term "proper subexpression" rather than
just subexpression.
> The standard's usage of the term is consistent with an expression
> *not* being its own subexpression.
I believe it is (also?) consistent with whole expressions being
subexpressions of themselves (sometimes vacuously so). In one
case that I remember ("common subexpression elimination", IIRC)
the term loses some of its force if only proper subexpressions
(ie, less than full expressions) are admitted.
[toc] | [prev] | [next] | [standalone]
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Date | 2015-11-28 10:21 -0500 |
| Message-ID | <5659C68C.70004@verizon.net> |
| In reply to | #77305 |
On 11/27/2015 10:42 PM, Keith Thompson wrote: > James Kuyper <jameskuyper@verizon.net> writes: > [...] >> 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. > > Is an expression a subexpression of itself? If so, we could refer to a > "proper subexpression" much as we talk about "proper subsets". > > The standard's usage of the term is consistent with an expression *not* > being its own subexpression. I agree, which is why the definition I suggested above was intended to be designed to not support that interpretation. It's not that I thought about that issue directly - merely that I never considered the possibility, and my definition reflects the fact that I didn't consider it a possibility.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.c
csiph-web