Requesting advice how to clean up C code for validating string represents integer

  • Thread starter robert maas, see http://tinyurl.com/uh3t
  • Start date
R

robert maas, see http://tinyurl.com/uh3t

From: "Malcolm McLean said:
In the C standard the term "object" has a very specific
definition. When most C programmers use the term "object" they
are not using it in this sense, probably even when specifically
discussing C.

Maybe. I'm still wondering what "region" means in the definition.
The standard is an important document,

In specifying behaviour of C programs and the syntax that generates
that behaviour, but:
so we can hardly hold that it is wrong to use its terminology,

Not necessarily so. I don't quite see how the ANSI/ISO standard
requires us to use terminology in any particular way when
discussing C in any context other than further work on the standard
itself.
even where it is somewhat eccentric.

Yeah. Now you're warming up.
However we cannot allow it to totally dictate our discourse.
There aren't enough words for that.

I.e. if all the words we would normally use are re-defined by the
government to be useless to us, and we are disallowed from using
the words in the old way or any other way, the we become unable to
carry on effective discussion. Orwell in 1984 predicted something
like that, and ANSI/ISO and IAU seems to have shown him correct.
(Not to mention the military too!)
Or in programming terms, they have polluted our namespace.

Ah, now you're at the top!! Perfect wording, even if a bit C++ish.
I'm usually one for fighting pollution, whether it be "military
intelligence" or "friendly fire" or "collateral damage" or
cigarette smoke or monosodium glutamate or nipponese/engrish. So
maybe this part of this thread is part of the war on pollutions.

But every so often one of these is rather humorous:

-- Babel Fish Translation of the Day (from Spanish):
I have an antenna of satellite in the roof, and a neighbor malafolla
me disoriented it whenever she raised to tend, until I greased it of
motor fat, random change in the design that was in an improvement of
the stability of the signal.
 
R

robert maas, see http://tinyurl.com/uh3t

From: CBFalconer said:
I believe the referenced page is authored by Maas.

Yeah. The online documentation I was reading, about the GNU C
compiler, seemed to say those functions were additions to C.
Perhaps that documentation was written prior to the 1999 standard
and hasn't yet been updated. Now I wish there was a plain-ASCII
version of the 1999 standard accessible so I could refer to it
instead of having to collate various random documentation I find
elsewhere. Anyway, I've pretty much decided to distinguish between
pre-1999-standard functions which all existing C compilers would
have, and new-in-1999 functions which some compilers such as GNU C
may have had before then but might still be missing in some
compilers somebody might be trying to use to learn C. Unfortunately
without access to the 1999 standard, this decision will be
difficult to implement. Accordingly I plan to downplay the
distinction, pretend *all* functions I find *anywhere* are in fact
available *everywhere* except per footnote hardly anyone will
bother to read but which will cover my ass in case of dispute (like
that fine-print warning label on consumer products). Since I'm not
getting paid for any of this work, why should I care if somebody
asks for their money back? What money??
If Yevgen scans old posts in this newsgroup for Maas's posts
(google is handy for this), and the myriad corrections required,
he may be able to evaluate the accuracy of that page, at least as
far as it applies to C.

The real test of C understanding is the ability to get software
working, especially getting it safe against user input, especially
in this day of deliberate crafting of viruses/worms/trojans/bots
which take advantage of any possible memory leak/eavesdrop/overwrite.
Hmm, I wonder if MS-IE and MS-Windows are written in C and that's
part of why MS can never quite get them secure against trespass?
For example, buffer overflow is natural with pointer arithmetic,
all you need is a teensy programmer bug overlooked admist the
kilometers of source code that needs eyeballing to find anything,
but buffer overflow is impossible in Java or Common Lisp.
Is 20% speed gain really more important than security?
</flamebait>
^ attempting to close an element which was not open
(another thread, check on Google if you're curious)

But the test of participation in a newsgroup is whether people
learn new things, no matter how much they didn't know at the start.
I've learned several things so-far in this thread, perhaps nothing
useful [1], but still interesting.

[1] StarTrek-TOS reference: "It does not feed Vall ..."
"A man who is right every time is not likely to do very much."
-- Francis Crick, co-discover of DNA

That's a great quote to use in rebuttal to your comment about my
ignorance early in this thread. I've done a lot of research, which
involves trying a lot of bad ideas, but discarding most of them
quickly enough to still allow time for pursuing the better ideas
and thereby achieving lots of various successes. (Well, *technical*
successes anyway. I still haven't found a way to market any of my
major inventions, and since I passed 40 I haven't even been able to
find anybody willing to hire me for routine software work.)

To play a guessing game based on my many technical successes:
<http://shell.rawbw.com/~rem/cgi-bin/topscript.cgi>
Select: (*) Random words from file
Then click on: Start the demo of SegMat per above selections
To pick a different example, go back up and click Start the demo again.
Lather, rinse, repeat.
 
C

CBFalconer

Yeah. The online documentation I was reading, about the GNU C
compiler, seemed to say those functions were additions to C.
Perhaps that documentation was written prior to the 1999 standard
and hasn't yet been updated. Now I wish there was a plain-ASCII
version of the 1999 standard accessible so I could refer to it
instead of having to collate various random documentation I find
elsewhere. ...snip ...

There is. See <http://cbfalconer.home.att.net/download/>

Please don't remove attributions for material you quote. And
please do not remove blank lines between paragraphs, quotes, etc.
 
S

santosh

robert said:
Yeah. The online documentation I was reading, about the GNU C
compiler, seemed to say those functions were additions to C.
Perhaps that documentation was written prior to the 1999 standard
and hasn't yet been updated. Now I wish there was a plain-ASCII
version of the 1999 standard accessible so I could refer to it
instead of having to collate various random documentation I find
elsewhere. Anyway, I've pretty much decided to distinguish between
pre-1999-standard functions which all existing C compilers would
have, and new-in-1999 functions which some compilers such as GNU C
may have had before then but might still be missing in some
compilers somebody might be trying to use to learn C. Unfortunately
without access to the 1999 standard, this decision will be
difficult to implement.

You'll have to buy the actual Standard, but the latest working paper,
which includes two added Technical Corrigenda is available for free:

<http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf>

CBFalconer has a pure text version of the final C99 draft at:

<http://cbfalconer.home.att.net/download/n869_txt.bz2>

<snip>
 
F

Flash Gordon

robert maas, see http://tinyurl.com/uh3t wrote, On 24/02/07 17:04:
Yeah. The online documentation I was reading, about the GNU C
compiler, seemed to say those functions were additions to C.
Perhaps that documentation was written prior to the 1999 standard
and hasn't yet been updated. Now I wish there was a plain-ASCII
version of the 1999 standard accessible so I could refer to it
instead of having to collate various random documentation I find
elsewhere. Anyway, I've pretty much decided to distinguish between
pre-1999-standard functions which all existing C compilers would
have, and new-in-1999 functions which some compilers such as GNU C
may have had before then but might still be missing in some
compilers somebody might be trying to use to learn C. Unfortunately
without access to the 1999 standard, this decision will be
difficult to implement.

It's a good job you have access to it then, isn't it. If no one has
given you the details before, then go here
http://www.clc-wiki.net/wiki/c_standard and follow the links.
> Accordingly I plan to downplay the
distinction, pretend *all* functions I find *anywhere* are in fact
available *everywhere* except per footnote hardly anyone will
bother to read but which will cover my ass in case of dispute (like
that fine-print warning label on consumer products). Since I'm not
getting paid for any of this work, why should I care if somebody
asks for their money back? What money??

So you want to make your page a pain for your intended audience. How
kind of you.
The real test of C understanding is the ability to get software
working,

According to that statement and your web page that means you do not
understand C. Your cookbook still has this prototype given in what is
meant to be C "int g2(int n1,n2);" despite it having been pointed out to
you and you having read the post and commented about it.
> especially getting it safe against user input, especially
in this day of deliberate crafting of viruses/worms/trojans/bots
which take advantage of any possible memory leak/eavesdrop/overwrite.

If you don't understand the language then how do you expect to be able
to develop anything that is robust?
Hmm, I wonder if MS-IE and MS-Windows are written in C and that's
part of why MS can never quite get them secure against trespass?

I would currently trust software from MS a lot more than I would trust
software from you.
For example, buffer overflow is natural with pointer arithmetic,
all you need is a teensy programmer bug overlooked admist the
kilometers of source code that needs eyeballing to find anything,
but buffer overflow is impossible in Java or Common Lisp.

I've never had to go back over all of any significantly complex program
I've written.
Is 20% speed gain really more important than security?

Depends. Do you want to crash in to the car in front because your breaks
did not apply in time? There are times when speed (or consistency of
speed) is just as important a requirement as any other.
</flamebait>
^ attempting to close an element which was not open
(another thread, check on Google if you're curious)

But the test of participation in a newsgroup is whether people
learn new things, no matter how much they didn't know at the start.
I've learned several things so-far in this thread, perhaps nothing
useful [1], but still interesting.

If you have learnt nothing useful then you have missed the point of a
lot of posts.
[1] StarTrek-TOS reference: "It does not feed Vall ..."
"A man who is right every time is not likely to do very much."
-- Francis Crick, co-discover of DNA

That's a great quote to use in rebuttal to your comment about my
ignorance early in this thread. I've done a lot of research, which
involves trying a lot of bad ideas, but discarding most of them
quickly enough to still allow time for pursuing the better ideas
and thereby achieving lots of various successes. (Well, *technical*
successes anyway. I still haven't found a way to market any of my
major inventions, and since I passed 40 I haven't even been able to
find anybody willing to hire me for routine software work.)

Based on what I've seen so far I would not hire you. There are far too
many misconceptions in your web pages, such as being able to compare
unrelated pointers, right shifting a negative number 0 fills, * being
for dynamically allocated objects only, [] being for "static-allocated"
objects only.
 
R

robert maas, see http://tinyurl.com/uh3t

From: Yevgen Muntyan said:
I figured it'd better to ask instead of stating that something is
nonsense, this thread shows that the former is more likely to work.

The first lesson I learned when I first had access to newsgroups
(via mailing lists at the time, I didn't get direct newsgroup
access until about ten years later) was that asking a question
hardly ever results in anyone providing an answer whereas posting a
wrong guess usually does elicit corrections which thereby provide
an answer to the actual question.

Unfortunately I'm too shy to deliberately post guesses as if
answers, so most of the time I post a question and it never gets
answered. I have a large list of SQWA (Specific Questions Waiting
for a Answer) from long ago. Nowadays the net is slightly better at
getting questions answered, so maybe I should pull out my old SQWA
list and try asking some of them to see if I can finally get
answers. Unfortunately my diskettes where all my old files are
archived aren't readable lately, and this tiny "apartment" (smaller
than a motel room) doesn't have enough space near the computer to
plug in my SyQuest drive where I have a backup of the diskettes.
If this guy knows google-fu well enough,

I don't know that language. I did a Google search on that term, and
the first match told me it's a take-off from Kung Fu jargon: It
means mastery of picking effective Google search terms to find
desired information. Just about the first thing I learned from
doing searches (Lycos, Web Crawler, AltaVista, etc.) is that if I
know the specific jargon keyword for a topic, and that's a rare
word in ordinary usage, then I get results, but any time I have to
use common ordinary words as search terms I get dismal results.
It's not like Kung Fu where you can have great skill. It's more
like whether you are fortunate to know the specific jargon or not.

WikiPedia is helping by collecting together lots of various
references under an "umbrella" of some common everyday term,
including disambiguation pages, whereby you can be led to the
appropriate jargon, after which a regular search is likely to
succeed, except at that point WikiPedia has probably answered your
question already so you don't need to do the search now.
he can even get readers,

I have no idea how mastery of picking good search terms to get
answers to questions would help me find readers for my
multi-programming-language "cookbook".
and those readers might even read what he wrote out there.

Isn't that a bit redundant, like wet water?
Silly code pieces are not as bad as things like "GNU-c" or what
he says about character type.

Hmm, I looked it up in K&R just now to refresh my memory. It seems
type 'char' is a single byte of memory, but that might be signed or
unsigned, might be 8 bits or 9 bits, might be ASCII or EBCDIC, and
if signed might or might not sign-extend when cast to an integer
type. Did I miss anything? Let me check what I say that might need
fixing ... hmm, I cleaned up a few comments about characters,
including inserting warnings about IBM mainframes that use EBCDIC,
how does it look now?

What do you mean by "silly code pieces"?? Do you mean examples of
how to use the basic operations I've described, including live
CGI-runnable demo-applications? Except for the essential code to
interface to the CGI environment, which isn't explained, just
presented for everyone to copy/adapt/rewrite, I don't have any such
examples yet, at least nothing more complicated than adding 1,2,3
to the number you entered in the form and watching it wrap around
if you enter close to the maximum allowed value for that datatype.
(And watch it *not* wrap in the lisp example.)
The former won't be used by anyone,

I've actually started to use it myself on occasion. Sometimes when
I want to relate two data types it's easier to look in my Matrix
than to look in the regular documentation. I presume as I get it
more complete it'll be more useful in that way, not just to me
(somebody who knows what I've put in already, just can't remember
the details without looking back at it), but to others (who have no
idea what's included and what's missing and present would be rather
frustrated at the mere 5-10% coverage, like 50% of c, 40% of
equivalent c++, and only a tiny fraction of the other four
languages).

(No, that's not a *subtraction* minus there between 5 and 10, no
matter how you might feel. Should I have used .. instead?)
the latter will be memorized, unintentionally.

Why would anybody bother to memorize something that's available
online for reference any time they want?? Besides, by the time any
large number of peple see my work, you have spotted all the
mistakes and prodded me into fixing them, right?
Anyway, too tired to speak English.

Hey, maybe you can help me with my foreign-language translations?
BabelFish is giving me really weird results most of the time:
For example:
! the President congratulated to all those that have been able to remove
! in front of form consensuada la reform from the Statute de Baleares
or:
! the President emphasized in the plenary session of the Senate,
! where occurred Balearic to the approval to the new Statute of,
! which this reform has gone in 'better direcci{o'}n' and shows that
! is compatible el avance of our country con el increase of the
! self-government, of the competitions, of the proximity of the
! institutions to administered and with reconocimiento de the
! 'plural one, rich and singular' identity of the Balearic islands

At least this one is close enough that I can figure out what it means:
! Rodriguez Zapatero and the president of Korea South del commit
! themselves to favor greater commercial interchanges")

Hmm, maybe I should write a BabelFish converter for software!
Select the language pair:
[C to C++ ]
[C to Lisp ]
[C to Java ]
[C to Perl ]
[C++ to Lisp ]
[C++ to Java ]
[Java to Lisp]
[Perl to Lisp]
[Perl to Java]
[Perl to PHP ]
(Does anybody notice the deliberate directional bias?)
 
K

Keith Thompson

Maybe. I'm still wondering what "region" means in the definition.

It's an ordinary English word for which the standard provides no
specialized definition. Do you also wonder about the meanings of
"of", "data", and "storage"? The standard does not attempt to be an
unabridged dictionary.

If the standard's definition of "object":

region of data storage in the execution environment, the contents
of which can represent values

confuses you, then this is the right place to ask for clarification.
I suspect that producing a definition for "region" won't make it any
clearer; any such definition must use other words, which themselves
need to be defined.
In specifying behaviour of C programs and the syntax that generates
that behaviour, but:


Not necessarily so. I don't quite see how the ANSI/ISO standard
requires us to use terminology in any particular way when
discussing C in any context other than further work on the standard
itself.

The standard does not *require* us to use its terminology. In fact,
the standard doesn't require anybody to do anything. It's effectively
a contract between implementers and users, but no implementer or user
is *required* to accept it. You can write a non-conforming C compiler
if you like, and you can write non-portable C programs if you like;
nobody is going to arrest or sue you for doing so, unless perhaps you
fraudulently claim comformance. (There may be some externally imposed
requirements to conform to the standard; if so, it's up to you to meet
those requirements or not.)

*However*, this newsgroup, by general consensus of (most of) the
participants, discusses the C programming language as defined by
(various versions of) the C standard, and we find that using terms as
the standard defines them makes communication much easier.

If you choose to use terms defined by the standard in ways that
conflict with the way the standard defines them, nobody is going to
come pounding on your door in the middle of the night. You're just
going to have difficulty communicating in this newsgroup.

If you use a term that's defined by the standard, I (and probably
others) will assume that you meant to use it in accordance with the
way the standard defines it. If your usage is clearly inconsistent
with that, I (and probably others) will probably point it out as an
error on your part -- or we might not bother. That's the reality
here. Nobody is asking you to agree that it's a good thing; I'm
simply informing you of the way things are. You can deal with it, or
you can find yourself in a lot of killfiles -- because nobody requires
*us* to communicate with *you* if you're unwilling to follow a
reasonable set of guidelines.

You're perfectly free to use the term "object", for example, in its
OOP sense; if you do so, I advise you to make it explicit that you're
using it that way. It's really not difficult.

[snip]
 
K

Keith Thompson

Yeah. The online documentation I was reading, about the GNU C
compiler, seemed to say those functions were additions to C.
Perhaps that documentation was written prior to the 1999 standard
and hasn't yet been updated. Now I wish there was a plain-ASCII
version of the 1999 standard accessible so I could refer to it
instead of having to collate various random documentation I find
elsewhere.

Are you unable to read PDF files? I understand you're using an old
and limited computer system, but there are cost-free PDF viewers that
should work for you.

If you can't deal with PDF, search for "n869.txt"; it's a committee
draft dated Jan 18, 1999. There are a few significant differences
between n869 and the actual C99 standard.
Anyway, I've pretty much decided to distinguish between
pre-1999-standard functions which all existing C compilers would
have, and new-in-1999 functions which some compilers such as GNU C
may have had before then but might still be missing in some
compilers somebody might be trying to use to learn C. Unfortunately
without access to the 1999 standard, this decision will be
difficult to implement. Accordingly I plan to downplay the
distinction, pretend *all* functions I find *anywhere* are in fact
available *everywhere* except per footnote hardly anyone will
bother to read but which will cover my ass in case of dispute (like
that fine-print warning label on consumer products). Since I'm not
getting paid for any of this work, why should I care if somebody
asks for their money back? What money??

You're creating a reference work and making it generally available.
In my opinion, you have an ethical obligation to make it as accurate
as possible, for reasons that have nothing to do with money. That is,
as I said, merely my opinion.

[...]
 
R

robert maas, see http://tinyurl.com/uh3t

From: Chris Dollin said:
/I'm/ not confused. Not about this.

You can't assign to a value. You can only assign a value, to
something else, something not a value. It makes no sense to assign
*to* a value. I'm not talking about <jargon>dereferencing</jargon>
(actually indirect-address or index-register storing in more
sensical machine-language jargon) a pointer value. Now if you want
to make the claim that an lvalue in c is really a pointer, I'd be
willing to listen to your argument. But I'm not going to just
assume you mean that unless you say so and give some reasoable
argument that it covers all cases. (Hmm, if this were baseball, the
cliche would be covers all bases. You get it? Agreement of first
letter of word. Nah, that's just a coincidence.)
The /evaluation/ of the expression `x` will yield an lvalue,
which we can usefully think of as "the address of x".

I have no idea what "evaluation" means in c. In Lisp it means
passing a data-structure to the function EVAL and getting back the
'evaluation' of that expression. There's nothing like that in c,
and in Lisp you certainly don't get back the address of the
expression or anything equivalent or even close.

In fact what you said makes no sense. The address of the expression
is the location of the 'x' byte in the source code. That's the only
place the expression 'x' is located where it could be found later,
in the source file. There's a copy of that byte from the source
file momentarily during compilation, but not anywhere you could
post an address where to find it still there later. If it's
declared external, then there's a symbol-table entry for it in the
compiled object file, to be used by the linker/loader. But at run
time there's no access to either the source file or the linker
symbol table.

So let's back off a bit. This so-called 'evaluation' which you
claims happens in c, happens when/where? In the compiler during
compilation? Or at runtime?? Or some other time?
I admire your ability to produce a cogent and informed argument.

I worry about your ability to juggle junk jargon.
Expressions that "denote a place" are those that can be evaluated
for their lvalues. Those that don't, can't.

What does "evaluated" mean in the context of c?
An 'lvalue' is *not* any kind of value, right?
You can't pass an lvalue as an actual argument to a function,
nor return a lvalue as the result from a function,
nor read an lvalue from an input file,
nor write a lvalue to an output file,
nor store an lvalue somewhere,
nor define a struct to have an lvalue as one of its component slots,
nor define an array of lvalues,
right?
Consider something like
fun f( x ) = ... x := x + 1 ...
... f( 1 ) ...
in a language with pass-by-binding (the formal argument is
bound to the (l)value of the actual argument). The body of
`f` can dink around with `x`, even if the actual argument
is a literal, and without affecting /all/ the places where
the value of `1` is required.

That sounds to me more like the dreaded "undefined behaviour".
For example, suppose in some implemetation of that hypothetical
programming language, all literals are pooled. So wherever the
literal value 1 occurs in a program, that piece of code always
references that single memory-location where that 1 is located in
the pool. So when that f(1) call is executed, the code that gets
executed (assuming passing args via registers) is something like:

load ix1,adr1 ;Loads address of pool1, into index register 1
jsr f

f: load reg1,0(ix1) ;Loads value 1 from pool1, into general register 1
add reg1,pool1 ;Adds value 1 from pool1, getting value 2
store reg1,0(ix1) ;Stores value 2 to pool1
ret

adr1: address pool1 ;Address of pool1, which itself is also in the pool
pool1: integer 1 ;Initial value of 1 in the pool, changed by call to f

Now pool1 contains the integer 2, so if f is ever called again
it'll add 2 to its argument.
Your FORTRAN example demonstrates why it can be better for each
(l)evaluation of `1` to yield a /new/ lvalue, not the same one
every time.

You mean you'd actually be willing to write applications in a
programming language where every time you pass a literal to a
function it allocates more memory and copies the literal to the new
memory and tells the function where to find that newly-allocated
memory containing the copy of the literal?? Since the function
might keep a copy of the pointer, and store that pointer other
places, you can never release that memory, because you have no way
to know if somebody else is still referencing that allocated copy
of the literal. Talk about memory leak!!! (Don't you ever complain
that Lisp is slow or wastes memory after what you've just
advocated!!)

Alterately I suppose you could avoid the memory leak by allocating
a static or stack variable for each such constant-copy storage
location. Effectively it'd be as if you had written this instead:
{ int tmp = 1;
f(tmp); }

With that restriction, you can do that already in C, coding all
those call-by-address yourself:
{ int tmp = 1;
f(&tmp); }
And if you don't want to erase those side-effects each time you are
back at this same piece of code, write this instead:
{ static int tmp = 1;
f(&tmp); }
So just write a replacement for all the standard libraries where
all arguments are pointers to the actual argument, and write all
your own functions the same way, and always use & to pass addresses
of actual arguments, and the C compiler will already forbid you
from saying f(&1).

Now back to the original idea of allocating new memory for each
call: If you're talking about a system with automatic garbage
collection like lisp, then of course there's no memory leak. I
actually started work on a lisp-like system that always passed
addresses so that any function could modify the variable or array
element or structure slot or any other variable place that was
passed (and of course you'd be forbidden to pass literals or other
constants directly to a function that modifies its argument,
because the compiler would know they had the 'const' property like
in C++, so they can be passed only to parameters which also have th
'const' property).
(`affect`, not `effect`)

Oops. Typo.
No; in fact you don't. You can have a uniform way of /updating/
the store, and different ways of computing the lvalue. Since
the update is "done" by an operation which is roughly
update( store, lvalue, rvalue )

The PDP-10 had something like this called a "byte pointer", which
provided as a unit all of:
- the machine address of the word containing the byte
- the offset of the byte within the word
- the number of bits in the byte
So if your storage units were always smaller than a 36-bit machine
word and never crossed a word boundary, you could specify a
"location" of a byte via a "byte pointer". The instructions LDB
(Load Byte) and DPB (Deposit Byte) did the obvious thing (loading a
byte and shifting into rightmost part of word, or shifting byte out
of rightmost part of word to desired part when storing).

So a single byte pointer could refer to anything from a single bit
(such as in an extremely large bit array where you have to pack the
bits rather than spread them one-per-word) up to a full 36-bit
word. Thus a byte pointer could be the 'lvalue' you speak of.

On virtually any other machine class, you'd need a struct to
represent an lvalue as a single unit of information. I don't see
that ever used in general, due to lower efficiency compared to
bypassing that level of abstraction to generate the specific
machine code needed directly from the parse tree of the source.

Also, I don't understand what that parameter 'store' is in your
call to the update function/macro. Is that an ENUM constant, to
select one of several types of update operation (the other value of
that ENUM perhaps being 'load'), or do you really have a parameter
called 'store' and if so what value do you pass as the 'store'
parameter??
That's a matter of opinion: whether it's a "clarification" to
make assignment depend on that systematic use of macros is ...
a choice.

All programming languages (except some assembly languages) have a
set of compiler rules, such as when the compiler sees anything of
the form
arr[index] = something
it generates code to compute the address of an array element and
the store some value into the memory location pointed-at. Whether
these are called rules or macros makes no difference in concept,
except that Common Lisp allows any old user to extend the set of
such compile-time interpretations of source code to work with new
user-defined structures just as well as it always worked with
language-defined structures such as arrays.

But that's not the point I was making. My point is that any
source-expression pattern that when used on the right side of a
assignment generates code to fetch a value from a slot within some
data structure, can in principle just as well be used on the left
side of a assignment to generate code to store a value in the same
place. The place where you fetch or store a value is *not* itself a
value, it's just a **place** (or slot). The data entity which you
fetch or store, *that* is a value. There's a difference between a
place, where values are located, and a value, which is stored at
some place. To use 'lvalue' to represent a place where a value is
stored, but to use 'rvalue' to represent the actual value, is
assymetric, and IMO midrot jargon. Better to have symmetric jargon.

Analagously there's difference between an address, such as "140
Main Street" (quotes because I'm talking about the address, what
you see on an envelope, not whatever is at that address), and
whatever is at that address, such as a vacant lot or a house or
office building. (Hmm, I checked with Google, and it's a three
bedroom house for sale, at least at that address in one town in CT
anyway.) I would never refer to the address as an lhouse, like
saying "be sure to write the lhouse on the envelope".

I suppose you could think of the so-called lvalue as a city lot, on
which at various times there might be a grassy pasture or a
Victorian house or a demolished house or a newly rebuilt Eichler
house or another demolished house or a block of apartment buildings.
I don't like calling the house a rvalue and the lot it's on an lvalue.

Gee, it's so easy to get sidetracked by Google. In another city
(namespace), the corresponding address has an antique shop, and in
another it's part of a hotel.

Or think of a toilet stall and whoever happens to be using that
stall at any particular time. Is the person an rperson and the
stall an lperson??
Why do you think using C will do that? It's not as though I'm
unfamiliar with Lisp, after all.

Oh. Since most people here aren't familiar with lisp (after all,
why would anybody use c, except for writing operating systems such
as Linux), after they have seen the light of how much better lisp
is), and since you seem to dismiss all lisp jargon, I just assumed
you weren't as familar with lisp as you are with c. Also for the
benefit of the other "you"s, as in "you-all", all the readers of
this thread, not just you singular. So I thought in a c group it
would be polite to express an algorithm in c if it was easy.
You can do something very similar using Pop11's updaters. They
don't use macros to do it: they use functions plus one assignment
rewrite rule.

"assignment rewrite rule" sounds to me like another way of saying
"setf method". How are they in any way different conceptually?
You somehow tell the compiler what code to actually generate with
it sees function(args) on left side of assigment, by some kind of
rewriting it to call a different function that is used for storage,
or maybe the same function but with a different parameter
combination that invokes storage instead of fetch, right? Or did I
miss what "assignment rewrite rule" means? How is "rewrite" any
different from "macro" in general anyway?? A macro is nothing but a
way of rewriting the source code so something newly generated (the
result of the macro-expansion or source-rewrite) will be compiled,
right?

I tried a Google search on that, but couldn't find relevant info
before I got really tired and in need of a nap.
 
C

CBFalconer

.... snip ...

The first lesson I learned when I first had access to newsgroups
(via mailing lists at the time, I didn't get direct newsgroup
access until about ten years later) was that asking a question
hardly ever results in anyone providing an answer whereas posting a
wrong guess usually does elicit corrections which thereby provide
an answer to the actual question.

.... snip 100 lines on various subjects ...

You might do better with short, to the point, articles, rather than
your present rambling largely incoherent style. You are also
allowed to match the subject line with the article.
 
Y

Yevgen Muntyan

Flash said:
Yevgen Muntyan wrote, On 20/02/07 03:54:

As a strong supporter of sticking to standard C where possibly I
strongly disagree. There are a vast number of system specific functions
which are extremely useful, it's just that they are not topical here.

"of general use" was meant to say something like "which do stuff
you'd need in your cookthing". How many useful functions
do you know which are GNU-only, BSD-only, Whatever-only,
and which are useful enough to write somewhat-portable
programs? Say, strndup() is GNU-only (at least man page
says so, and it's not available in FreeBSD). You use it,
and your program doesn't compile on *BSD. It is a useful
function, but it's one of those which help to produce
"unix" software which works only on linux.
Anyway, of course there is lot of system-specific functions
which do lot of good. Do you not agree this guy should not
put those in his cooksomething?
I'd still be interesting to see *vast* number of functions
like that which do something of interest in that cookthing.
Very poor advice. You will leave all the poor users of Visual Studio
Express wondering why they don't have snprintf (only _snprintf IIRC
which has significant differences) etc.

Then those poor people will learn their implementation sucks. Have
you seen swprintf function from microsoft? Should we avoid talking
about swprintf() because microsoft users will wonder why the function
is there but produces compilation errors? Anyway, the key part was
"imagine what reader will know after reading your stuff". "stick to C99"
is better than "provide random information like 'GNU-c'".
[snip]
By the way, I hope my readers will look up the complete definition
of the function, using Google for example, any place my quickie
definition isn't quite complete in all details.

Is this how *you* get the documentation? You should consider something
better, like C libraries manuals, man pages, C standard. man pages
are pretty good, they tell you about the standards given function
conforms to.

When did you last look at the man pages on SCO, AIX, IRIX etc... I'm
sure some of them do what you say, but you do not know that all man
pages do not that the versions installed on the OPs system do. The
bibliography of the comp.lang.c FAQ references some good books and the
comp.lang.c FAQ is good.

I'll be surprised if that guy is reading man pages on SCO, AIX, IRIX.
Anyway, I wasn't telling the "How you should write documentation".
I have no idea how to write good documentation. But I *do* know
that man pages he will be reading are most likely better than
what he has.
Now, FAQ is just great, but FAQ is not a reference. Standard
is the best, but somehow I think that if one can read the standard
he simply won't consult man pages (except to check if implementation
agrees with the standard). If man pages suck, it's unfortunate.
Perhaps it'd be better to specify, read GNU or FreeBSD or (insert
something) man pages.
The best would be to shut down sites like that. If it's not
possible, then it's better if it contains stuff copied from better
sources than some made-up-cause-it-seems-so junk.

Dear newbie reading this stuff and thinking I am right: no way,
forget and ignore all I say.

Is this better now?

Yevgen
 
K

Keith Thompson

You're seriously messing up the attributions. Your news client should
handle this for you. Attribution lines shouldn't start with "From:";
some software inserts a '>' character in front of the word "From" at
the beginning of a line.

The block starting with "Actually, no.", and the one starting with
"/I'm/ not confused. Not about this.", were both written by Chris
Dollin. "No wonder everyone is confused." was written by robert maas.
You can't assign to a value. You can only assign a value, to
something else, something not a value.

An "lvalue", in the sense that Chris is using the word (which is not
the way the C standard defines it) is a value to which you can assign.
You can think of it as an address, or as a location. For example, given:

x = y + 1;

the expression x is evaluated for its lvalue (which indicates where to
assign the result of the RHS, without looking at the current
*contents* of x), and the expressions y, 1, and y + 1 are evaluated
for their rvalues (just ordinary values).

As has already been mentioned, though, the C standard uses a different
definition of "lvalue"; it's basically an expression that designates
an object.
I have no idea what "evaluation" means in c.

Evaluation is what happens when a value is computed from an
expression. It generally happens during program execution.

[huge snip]
 
Y

Yevgen Muntyan

robert said:
From: Yevgen Muntyan <[email protected]>
I figured it'd better to ask instead of stating that something is
nonsense, this thread shows that the former is more likely to work.

[snip why and how]

If you don't know something, just don't write docs about it.
If you don't know an answer for something, you may have
zillion reasons why you can't get an answer, but it doesn't
let you write guesses in form of documentation.
I don't know that language. I did a Google search on that term, and
the first match told me it's a take-off from Kung Fu jargon: It
means mastery of picking effective Google search terms to find
desired information.

There are two sides of it. One is searcher side, how to find something;
and another one is provider side, how to make google pick your
site. Hope you won't get to the other side ;)

[snip]
I have no idea how mastery of picking good search terms to get
answers to questions would help me find readers for my
multi-programming-language "cookbook".


Isn't that a bit redundant, like wet water?

It is.

[snip]
I've actually started to use it myself on occasion.

You don't count. Writing notes for yourself is totally normal.
Claiming your notes is a textbook or a reference of some sort
isn't. (You may say that you don't claim anything, but there
is no clear disclaimer "BEWARE" cross the pages, and people
searching internet to get information tend to trust web pages
they read)

[snip]
Why would anybody bother to memorize something that's available
online for reference any time they want??

This is the point! Simple things get memorized easily without
any effort. One may see "GNU-c", and then in months after that
make wrong decision because "hm, I recall it's not portable, let's
go other way". The danger of sites like yours is not that a careful
skeptical reader will trust it. No, it's some poor guy who just needs
to get some work done will read it, and later be beaten by it.
Besides, by the time any
large number of peple see my work, you have spotted all the
mistakes and prodded me into fixing them, right?

Of course not. You didn't notice warm feelings from many people
here to you? Regardless if you understand why they feel and think
this way or not, and regardless if they are right or not. Only
positive-minded careful critical review may help.

[snip]
Select the language pair:
[C to C++ ]
[C to Lisp ]
[C to Java ]
[C to Perl ]
[C++ to Lisp ]
[C++ to Java ]
[Java to Lisp]
[Perl to Lisp]
[Perl to Java]
[Perl to PHP ]
(Does anybody notice the deliberate directional bias?)

Maybe you should call your page "C and other funny languages
for LISP'ers"? Would help to avoid some confusion perhaps.

Yevgen
 
F

Flash Gordon

Yevgen Muntyan wrote, On 25/02/07 03:31:
"of general use" was meant to say something like "which do stuff
you'd need in your cookthing". How many useful functions
do you know which are GNU-only, BSD-only, Whatever-only,
and which are useful enough to write somewhat-portable
programs? Say, strndup() is GNU-only (at least man page
says so, and it's not available in FreeBSD). You use it,
and your program doesn't compile on *BSD. It is a useful
function, but it's one of those which help to produce
"unix" software which works only on linux.

It is a useful function, but one easy to replicate on other systems so
hardly critical.
Anyway, of course there is lot of system-specific functions
which do lot of good. Do you not agree this guy should not
put those in his cooksomething?
I'd still be interesting to see *vast* number of functions
like that which do something of interest in that cookthing.

Functions for networking (getting MACs for NICs is very useful but IIRC
you need to go beyond POSIX on nix boxes to do it), functions for
graphics, functions for threads etc.

If a "CookBook" is going to cover such things, which is not
unreasonable, then it will need to cover system specifics. Of course, it
should clearly mark what is system specific.
Then those poor people will learn their implementation sucks. Have
you seen swprintf function from microsoft?

If you tell them it is only in the latest standard and they find it is
not in the latest and greatest from <insert provider of dislike> then
they will not only learn that provider as not kept up but also what it
is the provider is not doing.
> Should we avoid talking
about swprintf() because microsoft users will wonder why the function
is there but produces compilation errors? Anyway, the key part was
"imagine what reader will know after reading your stuff". "stick to C99"
is better than "provide random information like 'GNU-c'".

Providing random information about system specific stuff is bad for one
set of reasons (although non-random clearly marked system specifics is
not). Sticking to C99 only is bad for different reasons.
[snip]

By the way, I hope my readers will look up the complete definition
of the function, using Google for example, any place my quickie
definition isn't quite complete in all details.

Is this how *you* get the documentation? You should consider something
better, like C libraries manuals, man pages, C standard. man pages
are pretty good, they tell you about the standards given function
conforms to.

When did you last look at the man pages on SCO, AIX, IRIX etc... I'm
sure some of them do what you say, but you do not know that all man
pages do not that the versions installed on the OPs system do. The
bibliography of the comp.lang.c FAQ references some good books and the
comp.lang.c FAQ is good.

I'll be surprised if that guy is reading man pages on SCO, AIX, IRIX.
Anyway, I wasn't telling the "How you should write documentation".
I have no idea how to write good documentation. But I *do* know
that man pages he will be reading are most likely better than
what he has.

This chap has given the impression that he is using some form of remote
system which he probably does not own or control. Therefore, for all we
know, it *could* be one of those systems and it may or may not have the
man pages installed and they may or may not be any good.
Now, FAQ is just great, but FAQ is not a reference.

The bibliography for the FAQ mentions a number of good books as I said.
> Standard
is the best, but somehow I think that if one can read the standard
he simply won't consult man pages (except to check if implementation
agrees with the standard). If man pages suck, it's unfortunate.
Perhaps it'd be better to specify, read GNU or FreeBSD or (insert
something) man pages.
The best would be to shut down sites like that. If it's not
possible, then it's better if it contains stuff copied from better
sources than some made-up-cause-it-seems-so junk.

I don't disagree with that, but unless you know what system someone has
access to then just recommending the man-pages is not quite a safe
option. Had you recommended a web site with man-pages (which do exist)
that you had checked were of decent quality, or had you known he was
using a system with decent man-pages it would be different.
Dear newbie reading this stuff and thinking I am right: no way,
forget and ignore all I say.

Is this better now?

Currently that warning belongs on Robert's site!
 
F

Flash Gordon

Yevgen Muntyan wrote, On 25/02/07 03:59:

You have not fixed all of the errors that have been pointed out to you.
Of course not. You didn't notice warm feelings from many people
here to you? Regardless if you understand why they feel and think
this way or not, and regardless if they are right or not. Only
positive-minded careful critical review may help.

The only was to get people to fully review it is to fix the problems
already pointed out and then ask for further review.
Select the language pair:
[C to C++ ]
[C to Lisp ]
[C to Java ]
[C to Perl ]
[C++ to Lisp ]
[C++ to Java ]
[Java to Lisp]
[Perl to Lisp]
[Perl to Java]
[Perl to PHP ]
(Does anybody notice the deliberate directional bias?)

Maybe you should call your page "C and other funny languages
for LISP'ers"? Would help to avoid some confusion perhaps.

Adding, "written by someone inexperienced in C and other languages"
might help.
 
Y

Yevgen Muntyan

Flash said:
Yevgen Muntyan wrote, On 25/02/07 03:31:

It is a useful function, but one easy to replicate on other systems so
hardly critical.


Functions for networking (getting MACs for NICs is very useful but IIRC
you need to go beyond POSIX on nix boxes to do it), functions for
graphics, functions for threads etc.

If a "CookBook" is going to cover such things, which is not
unreasonable, then it will need to cover system specifics.

"If", huh? Not unreasonable? Indeed, networking cookbook by OP is hardly
unreasonable. And, could you show vast number of GNU-only, SomeBSD-only,
Whatever-only functions, not just some random portablish POSIX,
Unix98, BSD functions?
Of course, it
should clearly mark what is system specific.


If you tell them it is only in the latest standard and they find it is
not in the latest and greatest from <insert provider of dislike> then
they will not only learn that provider as not kept up but also what it
is the provider is not doing.

Which shows you did *not* see it. It is in microsoft C libs, signature
is different. Now, you're saying "if you tell them...". Do you mean
one must inspect all implementations out there (or maybe only Microsoft
one?) and then post information about their conformance wherever one
posts very name of a single function? It would be good but
not realistic. The original advice "don't even try" *for the OP* holds,
I think.
Providing random information about system specific stuff is bad for one
set of reasons (although non-random clearly marked system specifics is
not). Sticking to C99 only is bad for different reasons.

Which alternative is better? Better not for ultimate truth or something,
but for people who can obtain wrong information from the site.
[snip]

By the way, I hope my readers will look up the complete definition
of the function, using Google for example, any place my quickie
definition isn't quite complete in all details.

Is this how *you* get the documentation? You should consider something
better, like C libraries manuals, man pages, C standard. man pages
are pretty good, they tell you about the standards given function
conforms to.

When did you last look at the man pages on SCO, AIX, IRIX etc... I'm
sure some of them do what you say, but you do not know that all man
pages do not that the versions installed on the OPs system do. The
bibliography of the comp.lang.c FAQ references some good books and
the comp.lang.c FAQ is good.

I'll be surprised if that guy is reading man pages on SCO, AIX, IRIX.
Anyway, I wasn't telling the "How you should write documentation".
I have no idea how to write good documentation. But I *do* know
that man pages he will be reading are most likely better than
what he has.

This chap has given the impression that he is using some form of remote
system which he probably does not own or control. Therefore, for all we
know, it *could* be one of those systems and it may or may not have the
man pages installed and they may or may not be any good.

"Could", indeed. It *could* be that man pages on the system he's using
are worse than what he's writing. While I can't deny such a possibility,
I doubt it's the case.
The bibliography for the FAQ mentions a number of good books as I said.

Which aren't read, if you didn't get it.
I don't disagree with that, but unless you know what system someone has
access to then just recommending the man-pages is not quite a safe
option.

I do claim man pages OP has access to (if any) are better than his
writing. I am not saying "could not be worse", I am saying "they are".
You can speculate what you want about possibilities, it won't change
a thing.
Had you recommended a web site with man-pages (which do exist)
that you had checked were of decent quality, or had you known he was
using a system with decent man-pages it would be different.

It would be different. If I were a real C specialist and corrected
everything, it'd be even more different.
But, to my best knowledge, my above statement is right. Could be wrong,
indeed, perhaps. But you better present an example of man pages set
(OP could have access to as you say) which are worse than the
cookbook thing.

I am not sure what we are arguing about though. Did my advices
constitute a nice set of nice advices for folks writing docs?
Absolutely no. Did I recommend better stuff than the present content
of OP's site? Oh yes.

Yevgen
 
F

Flash Gordon

Yevgen Muntyan wrote, On 25/02/07 07:57:
Which shows you did *not* see it. It is in microsoft C libs, signature
is different. Now, you're saying "if you tell them...". Do you mean
one must inspect all implementations out there (or maybe only Microsoft
one?) and then post information about their conformance wherever one
posts very name of a single function? It would be good but
not realistic. The original advice "don't even try" *for the OP* holds,
I think.

No, I meant if you tell your *readers* that function X is C99 only and
your *reader* finds that is is not available in MS VC++, or whatever
other implementation, then your *reader* can judge on that basis whether
the company in question sucks.
Which alternative is better? Better not for ultimate truth or something,
but for people who can obtain wrong information from the site.

It is better to specify anything that is not C89 is not C89 and what it
actually is, be it C99, POSIX, MS, GNU or whatever. The only standard
fully implemented by most compilers is C89, in particular gcc document
that their C99 implementation is not complete and MS VC++ does not even
attempt it, and that covers the bulk of new users who are not using
something written before C99 was even published. So stick to C89 (not
C99) as the base and then specify things in C99 or whatever as
appropriate and appropriately documented.
[snip]

By the way, I hope my readers will look up the complete definition
of the function, using Google for example, any place my quickie
definition isn't quite complete in all details.

Is this how *you* get the documentation? You should consider something
better, like C libraries manuals, man pages, C standard. man pages
are pretty good, they tell you about the standards given function
conforms to.

When did you last look at the man pages on SCO, AIX, IRIX etc... I'm
sure some of them do what you say, but you do not know that all man
pages do not that the versions installed on the OPs system do. The
bibliography of the comp.lang.c FAQ references some good books and
the comp.lang.c FAQ is good.

I'll be surprised if that guy is reading man pages on SCO, AIX, IRIX.
Anyway, I wasn't telling the "How you should write documentation".
I have no idea how to write good documentation. But I *do* know
that man pages he will be reading are most likely better than
what he has.

This chap has given the impression that he is using some form of
remote system which he probably does not own or control. Therefore,
for all we know, it *could* be one of those systems and it may or may
not have the man pages installed and they may or may not be any good.

"Could", indeed. It *could* be that man pages on the system he's using
are worse than what he's writing. While I can't deny such a possibility,
I doubt it's the case.

I would expect that if there are man pages installed then they are
infinitely better than what he is writing. However, they may be no
better (or even worse than) what he finds when searching the net at
random. You just do not know.
Which aren't read, if you didn't get it.

I was suggesting that he *should* read the bibliography and get some of
those books and read them. If someone fails to follow advice that is not
a fault in the advice!
I do claim man pages OP has access to (if any) are better than his
writing. I am not saying "could not be worse", I am saying "they are".
You can speculate what you want about possibilities, it won't change
a thing.

I thought you were referring to the sorts of documentation the OP should
read. I agree that his site is far worse than useless.
It would be different. If I were a real C specialist and corrected
everything, it'd be even more different.
But, to my best knowledge, my above statement is right. Could be wrong,
indeed, perhaps. But you better present an example of man pages set
(OP could have access to as you say) which are worse than the
cookbook thing.

I am not sure what we are arguing about though. Did my advices
constitute a nice set of nice advices for folks writing docs?
Absolutely no. Did I recommend better stuff than the present content
of OP's site? Oh yes.

I think in this sub-thread we have been arguing at cross purposes. So to
summarise some of the points:

1) I think we both agree that the OPs site currently has negative value
2) We both agree that there are good man pages on some systems.
3) I think that rather than saying "read the man pages" one should
either recommend a good book or a site one *knows* is good (man pages
are in general not designed to teach).
 
Y

Yevgen Muntyan

Flash said:
Yevgen Muntyan wrote, On 25/02/07 07:57:
Flash said:
Yevgen Muntyan wrote, On 25/02/07 03:31:
[snip]
Which shows you did *not* see it. It is in microsoft C libs, signature
is different. Now, you're saying "if you tell them...". Do you mean
one must inspect all implementations out there (or maybe only Microsoft
one?) and then post information about their conformance wherever one
posts very name of a single function? It would be good but
not realistic. The original advice "don't even try" *for the OP* holds,
I think.

No, I meant if you tell your *readers* that function X is C99 only and
your *reader* finds that is is not available in MS VC++, or whatever
other implementation, then your *reader* can judge on that basis whether
the company in question sucks.

swprintf *is* available in MS libs. It's not compatible with C standard.
I somehow missed the importance of this fact (was satisified with "MS
sucks"). So now I completely agree with "stick to C89". There is a
question though: what C99 stuff is safe to use (safe meaning
either works fine or doesn't compile)?

Yevgen
 
F

Flash Gordon

Yevgen Muntyan wrote, On 25/02/07 09:59:
Flash said:
Yevgen Muntyan wrote, On 25/02/07 07:57:
Flash Gordon wrote:
Yevgen Muntyan wrote, On 25/02/07 03:31: [snip]
Which shows you did *not* see it. It is in microsoft C libs, signature
is different. Now, you're saying "if you tell them...". Do you mean
one must inspect all implementations out there (or maybe only Microsoft
one?) and then post information about their conformance wherever one
posts very name of a single function? It would be good but
not realistic. The original advice "don't even try" *for the OP* holds,
I think.

No, I meant if you tell your *readers* that function X is C99 only and
your *reader* finds that is is not available in MS VC++, or whatever
other implementation, then your *reader* can judge on that basis
whether the company in question sucks.

swprintf *is* available in MS libs. It's not compatible with C standard.

You find the same problem with the MS implementation of snprintf,
although they generally call it _snprintf. I was not aware they had some
where they used the standard name.
I somehow missed the importance of this fact (was satisified with "MS
sucks"). So now I completely agree with "stick to C89". There is a
question though: what C99 stuff is safe to use (safe meaning
either works fine or doesn't compile)?

Only the common subset of C99 and C89 unfortunately. Well, that is a
slight exaggeration, intermixing declarations and statements is likely
to either work or not compile, although I would not guarantee there were
no edge cases using goto an initialisers which would behave incorrectly
in a C89+extensions compiler. The gcc team provide documentation on the
status of their C99 support (although library issues are outside their
control) MS does not because it is not attempting to provide any C99
conformance.
 
C

Chris Dollin

robert said:
You can't assign to a value.

There are only values, so if assignment assigns to something,
it must be a value.
Now if you want
to make the claim that an lvalue in c is really a pointer,

I don't. (But is has some of the same behaviours.)
I'd be
willing to listen to your argument. But I'm not going to just
assume you mean that unless you say so and give some reasoable
argument that it covers all cases.

This is not the time nor the place for a tutorial on the
fundamental concepts of programming languages. So I won't
give one. Do your own homework.
I have no idea what "evaluation" means in c.

Not my problem.
In Lisp it means
passing a data-structure to the function EVAL and getting back the
'evaluation' of that expression. There's nothing like that in c,
and in Lisp you certainly don't get back the address of the
expression or anything equivalent or even close.

Not all languages are Lisp. Not all languages need the concept
of lvalue. Most people don't find these facts to be a problem.
In fact what you said makes no sense.

I think you misread it.
The address of the expression

.... is nothing to do with it. It's a red herring.
So let's back off a bit. This so-called 'evaluation' which you
claims happens in c

It's not /my/ claim. It's not "so-called" evaluation, either.
Can we dispense with the verbal smearing?
, happens when/where? In the compiler during
compilation? Or at runtime?? Or some other time?

It doesn't matter when, so long as the right [defined by specification]
answer is arrived at.
I worry about your ability to juggle junk jargon.

Don't worry. It's bad for one.
What does "evaluated" mean in the context of c?

See the C standard for details.
An 'lvalue' is *not* any kind of value, right?
Wrong.

You can't pass an lvalue as an actual argument to a function,
nor return a lvalue as the result from a function,
nor read an lvalue from an input file,
nor write a lvalue to an output file,
nor store an lvalue somewhere,
nor define a struct to have an lvalue as one of its component slots,
nor define an array of lvalues,
right?
Correct.


That sounds to me more like the dreaded "undefined behaviour".

It isn't. UB allows /any/ implementation.
For example, suppose in some implemetation of that hypothetical
programming language, all literals are pooled. So wherever the
literal value 1 occurs in a program, that piece of code always
references that single memory-location where that 1 is located in
the pool.

That would be an incorrect implementation of pass-by-binding
as described.
You mean you'd actually be willing to write applications in a
programming language

My willingness to write code in a language I'm describing is
not at issue, nor do I see why it should be; descriptive
techniques should be capable of handling languages I dislike
as well as ones I like.
Since the function
might keep a copy of the pointer, and store that pointer other
places, you can never release that memory, because you have no way
to know if somebody else is still referencing that allocated copy
of the literal. Talk about memory leak!!!

Garbage. Collection. Which I /know/ you know about.
(Don't you ever complain
that Lisp is slow or wastes memory after what you've just
advocated!!)

I /advocated/ nothing. You're fabulating.
The PDP-10 had something like this called a "byte pointer",

Yes, I know. I've known about the PDP-10 and its byte pointers
for years.
On virtually any other machine class, you'd need a struct to
represent an lvalue as a single unit of information.

You're confusing semantics with implementation.
Also, I don't understand what that parameter 'store' is in your
call to the update function/macro.

It's the store, the place where values live:

update( store, lvalue, rvalue )

delivers a new store which is the same as `store` except the
value at `lvalue` is now `rvalue`. Perfectly straightforward
denotational semantics. There are books.
But that's not the point I was making.

(snip some interestingly exotic/bizarre inventions of metaphors
for lvalues. lvalues are identifiers for places to put things,
as I think has been obvious since I opened my mouth on this
subject.)
Oh. Since most people here aren't familiar with lisp

I don't know how you'd know that.
(after all,
why would anybody use c, except for writing operating systems such
as Linux), after they have seen the light of how much better lisp
is), and since you seem to dismiss all lisp jargon,

I haven't dismissed /any/ Lisp jargon.
"assignment rewrite rule" sounds to me like another way of saying
"setf method". How are they in any way different conceptually?

There's only one rewrite rule, not one per "setf method".
You somehow tell the compiler what code to actually generate with
it sees function(args) on left side of assigment,

[Actually the right-hand-side, since Pop11's assignments run
left-to-right.]
by some kind of rewriting it to call a different function that

Yes: by calling that function's updater. The expression

V -> F(X) is compiled as (F.updater)(V, X)

[well, really, ->F(X) is compiled as (F.updater)(X), but we'll
leave aside the open stack for now.]
How is "rewrite" any different from "macro" in general anyway??

The rewrite is built in to the compiler. I would say "not user
redefinable", but Pop11's pretty open; given enough effort you
can pretty much redefine whatever you like. More to the point,
you don't change any rewrite rules and you don't create any
macros when you define Pop11's updaters.

And I'm done.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top