Path: csiph.com!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: "matt.ti...@gmail.com" Newsgroups: comp.compilers Subject: Re: What is the meaning of an expression? Date: Sat, 15 Jan 2022 06:21:08 -0800 (PST) Organization: Compilers Central Lines: 29 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <22-01-058@comp.compilers> References: <22-01-052@comp.compilers> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="52225"; mail-complaints-to="abuse@iecc.com" Keywords: semantics Posted-Date: 15 Jan 2022 12:28:43 EST X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com In-Reply-To: <22-01-052@comp.compilers> Xref: csiph.com comp.compilers:2834 > The meaning of an expression is the value of the expression. That is not true. This might be said in a magazine article written for laymen about programming languages, or in a philosophical context that doesn't refer to practical work. > The semantics of an expression is the value of the expression. That's not right either. The semantics of the *language* determine the meaning of expressions written in that language. The meaning of an expression is what you communicate to the compiler or to readers by writing that expression. In C, for example, int a = 1+1; means "declare a variable named a of type int, an initialize it with the value produced by adding the integers 1 and 1". The expression part of this, "1 + 1", means "the value produced by adding the integers 1 and 1". This is *not* the same as "2". The compiler may determine that it's equivalent to "2", and will *probably* not write out any actual addition instructions, but what you *wrote* is an addition, and its meaning is determined by the semantics of addition as defined in C. Of course, expressions in most languages can also include function calls and operators that produce side effects, like "printf("%d",++i);", which certainly has a meaning even though it produces no meaningful value.