A doubly linked-list in C

C

Chris Dollin

BartC said:
In C, try passing an array by value. You will find it can only be passed by
reference.

It looks like that, but it's not true.

If `A` is an array, in the call `F(A)` /there is no array to pass/.
`A` decays into a pointer to its first element, not because it's
an argument, but because arguments are expressions which don't
stop arrays decaying into pointers. By the time we get to passing
values, there's a pointer value to pass, and it's passed by value.

The /effect/ is much like "passing an array by reference". But you can
unpick the components and see that that is just a happy confluence of
other not-to-do-with-passing language features.
 
L

lawrence.jones

Well Fortran compilers pass everything by reference (or they
used to).

No, Fortran passed everything (except arrays) by copy/restore. To pass
by reference, you had to decorate the formal paramter name with slashes:

SUBROUTINE SUB1(I, /J/) I passed by copy/restore, J by reference

Pass by copy/restore is similar to pass by value except that the final
value of the parameter is copied back into the argument when the
subroutine returns.
 
K

Kaz Kylheku

John O'Flaherty skrev:

"Semantics" is always plural in form, but it is often treated as
singular in construction. This means that it is normal to write "the
semantics is".

Prescriptively speaking, ``Semantics'' is not plural in form. An ``s'' on the
end doesn't imply plural. ``Crisis'' is also terminated by s, and so is
``Jones''.

``Semantics'' is only ever a plural to those who don't have a clue that it
isn't, or make a mistake.
There are other similar nouns, such as "news", "mathematics", and
"politics". "News" is always treated as singular in construction;

``I heard many good news about that.'' Hmm.
"mathematics" is usually treated as singular in construction; and

I've never heard mathematics treated as a plural: ``many mathematics'',
``three different mathematics'', etc. Native English speakers rarely get this
one wrong, or so it has been my experience.
"politics", like "semantics", is frequently treated as singular in
construction.

Semantics is /infrequently/ treated as singular, because you have to have
a clue to do so. It's often discussed as a property of something; some
body of language has semantics. It sounds complicated, so there must be
more one of them. Perhaps as many as thirteen!

One romantic, two romantics. One semantic, two semantics. :)
 
M

Martin Ambuhl

John said:
It should be plural. I think "semantic" is always an adjective, i.e.
"semantics" doesn't have a singular. Parallel - you can't say "The
mathematic is wrong."

I would never presume to suggest that you are not more of an authority
than Adrian Akmajian, who in his chapter on semantics wrote: "Hence, if
a grammar describes a language, part of it must describe meaning, and
thus must contain a semantics."
(_Linguistics: An Introduction to Language and Communication_, MIT
Press, 1st ed. 1979:p229; 5th ed. 2001: p.228). If Akmajian were still
alive, I imagine you could teach him a thing or two.
 
J

James Silverton

Evan wrote on Wed, 22 Apr 2009 11:24:05 -0700:
Different sense. The language (and its utterances) contain
semantics. The grammar contains a semantics, which is a
description of the semantics of the language. Similarly, the
language will have syntax, while the grammar has a syntax.

I know the dictionaries (OED especially) agree with you but "a
semantics" sounds strange to me and "a semantic" is allowed. "A
mathematics", for a style or method of mathematics does not sound quite
so unfamiliar. Still, tho I would not write it formally, I might use "a
math".

--

James Silverton
Potomac, Maryland

Email, with obvious alterations: not.jim.silverton.at.verizon.not
 
M

Martin Ambuhl

Evan said:
Different sense. The language (and its utterances) contain
semantics. The grammar contains a semantics, which is a description
of the semantics of the language. Similarly, the language will have
syntax, while the grammar has a syntax.

In what way do you mean "different sense"? The fact is that John
O'Flaherty made the flat statement the "semantics" should be plural and
that "semantics" doesn't have a singular. His is an absurd claim:
"semantics" has a singular, and it is "semantics". Such ignorant
people, in John O'Flaherty's view, Frank R. Palmer in the article
"Semantics" in _The Oxford Companion to the English Language_ write:
"Post-Saussurean semantics is the sudy of meaning as a branch of
linguistics ...". Please demonstrate that a sentence beginning "The
semantics of the expression ..." requires a plural verb, if you can.
If you succeed, please write to the OUP editors and tell them to remove
their "usually treated as singular" tag which is used without any
attempt to discriminate such usual treatment for the sense you seem
ready to agree with John O'Flaugherty should be treated as plural.

If there is anything worse than a prescriptivist, it is one who is wrong.
 
I

Ian Collins

Richard said:
BartC said:



In C, try passing an array ***at all***. It can't be done, at least
not without tucking the array inside a struct or union.

Where it will be passed by value.
 
P

Phil Carmody

Barry Schwarz said:
Would you care to provide a reference to this explicit description.

Firstly, do you believe that words defined in the standard follow
the standard rules of conjugation/declension/participle-forming as
other words with the same parts of speech in English?

If you do - then you just need to apply those rules.

If you don't, then you'll find that much of the standard is using
undefined terms.

Phil
 
K

Kaz Kylheku

["Followup-To:" header set to comp.lang.c.]
I would never presume to suggest that you are not more of an authority
than Adrian Akmajian, who in his chapter on semantics wrote: "Hence, if
a grammar describes a language, part of it must describe meaning, and
thus must contain a semantics."

This is silly. Semantics is not a countable noun, and so the article ``a'' is
inappropriate. Akmajian might not be a native English speaker.

``Must contain a semantics'' is a a lot like saying ``must contain a air''.

The correct usage is ``must contain semantics''. (Better yet, ``must have
semantics''; containment isn't really the best analogy for the
association between a language and semantics).

Also, what he is saying seems somewhat strange (keeping in mind that it's out
of context). A grammar must contains semantics? What?

A language need not have any meaning; a grammar describes only syntax which is
devoid of meaning in and of itself. A grammar must be augmented with meaning in
order for the resulting language to have any. Otherwise all it does is
describe, in a condensed way, the set of possible strings of symbols that may
be generated (or parsed).

Of course the /description/ of a grammar has semantics: it is expressed in the
form of written phrase structure rules and those rules have a meaning; their
meaning is that they express a system of symbol rewriting. (Is what Akmajian
means here by the grammar having semantics?)

But that usually not the semantics that we are talking about when discussing
syntax and semantics with respect to some language. Of /course/ the tools
we are using, and the language in which we are discussing, have their own
semantics!
(_Linguistics: An Introduction to Language and Communication_, MIT
Press, 1st ed. 1979:p229; 5th ed. 2001: p.228). If Akmajian were still
alive, I imagine you could teach him a thing or two.

Sure, like perhaps how to to properly ask for directions from the airport
to the linguistic institute. :)
 
K

Keith Thompson

Kaz Kylheku said:
["Followup-To:" header set to comp.lang.c.]
I would never presume to suggest that you are not more of an authority
than Adrian Akmajian, who in his chapter on semantics wrote: "Hence, if
a grammar describes a language, part of it must describe meaning, and
thus must contain a semantics."

This is silly. Semantics is not a countable noun, and so the article
``a'' is inappropriate. Akmajian might not be a native English
speaker.

``Must contain a semantics'' is a a lot like saying ``must contain a air''.

"Semantics" is normally used as an uncountable noun, like, say,
"wine". But we can refer to a particular kind of wine as "a wine".
In a sense, "wine" (meaning the substance) and "wine" (meaning a
variety of that substance) are two different meanings of the same
word.

Similarly, I presume Adrian Akmajian was using the phrase "a
semantics" to refer to a kind of semantics, or to a particular
semantic (adj.) framework, or something like that. I can't be sure
without more context, but it seems to me to be a reasonable (though
jargonish) way to express the concept.

The word "grammar" works much the same way: you can have "grammar", or
you can have "a grammar", or two or more "grammars". Same for
"mathematics", though referring to "a mathematics" is probably less
common.

The fact that "semantics" and "mathematics" end in 's' can cause some
confusion; if you have "a semantics", what would you call two of them?
("semantices", maybe?)

[...]
 
R

Richard Tobin

Kaz Kylheku said:
Prescriptively speaking, ``Semantics'' is not plural in form. An ``s'' on the
end doesn't imply plural. ``Crisis'' is also terminated by s, and so is
``Jones''.

An "s" at the end of a word is not necessarily the plural indicator.
However, the "s" at the end of "semantics" *is* the plural indicator.
Though it is often interpreted as singular, it is plural in form.

-- Richard
 
R

Richard Tobin

Kaz Kylheku said:
This is silly. Semantics is not a countable noun

Yes it is. A semantics is a mapping from symbols to meanings. There
can be multiple mappings, so there can be multiple sematics. (It's
tempting to say "semanticses".)
``Must contain a semantics'' is a a lot like saying ``must contain a air''.

The correct usage is ``must contain semantics''.

You seem to be just ignorant of English as it is used in this
field. You may not like the usage, but it *is* the usage.

-- Richard
 
M

Martin Ambuhl

Kaz said:
["Followup-To:" header set to comp.lang.c.]
I would never presume to suggest that you are not more of an authority
than Adrian Akmajian, who in his chapter on semantics wrote: "Hence, if
a grammar describes a language, part of it must describe meaning, and
thus must contain a semantics."

This is silly. Semantics is not a countable noun, and so the article ``a'' is
inappropriate. Akmajian might not be a native English speaker.

Not only did this form stand in 5 editions over 32 years, escaping the
notice of the MIT Press editors and Akmajian's co-authors Richard
Demers, Robert Harnish, and Ann Farmer (all native speakers), but Frank
Palmer's use of singular 'semantics' went unnoticed by the OUP editors
in _The Oxford Companion to the English Language_. I can supply
multiple uses of singular 'semantics' in linguistics texts and English
language texts, but cannot do the same for plural 'semantics'. Just who
the hell is Kaz Kylheku to presume to tell the experts in linguistics
and English usage that they are wrong?
 
R

Richard Tobin

John O'Flaherty said:
Yes, you're right, it's singular in meaning, and you would say both
"the semantics is wrong" and "the mathematics is wrong". It's
interesting that the latter word is abbreviated "maths" in UK.

No, it's odd that it's abbreviated "math" in the US.
For the
abbreviation, would they say "the maths is", or "the maths are"?

"The maths is", of course. "John's maths is abysmal".

-- Richard
 
L

luserXtrog

Martin Ambuhl said:



'When I use a word,' Humpty Dumpty said, in a rather scornful tone,
'it means just what I choose it to mean, neither more nor less'.

Excellent! I've been tempted to post that very quote.

The unfortunate consequence of such a position is having
to give an explanation for each word used; which quickly
becomes an infinite task.
 
B

BartC

Ian said:
Where it will be passed by value.

That's a workaround to pass an array by value, and is not quite the real
thing:

If you pass array A by value, you expect to be able to index it using A
in the callee, not pass it disguised as B and have to access it using
B.A.
 
C

CBFalconer

Richard said:
No, it's odd that it's abbreviated "math" in the US.


"The maths is", of course. "John's maths is abysmal".

No no no. "Johns mathematics are abysmal." :)
 
A

arnuld

In C, try passing an array ***at all***. It can't be done, at least
not without tucking the array inside a struct or union.


It means if I put an array inside a struct, then it will be passed as
a *whole* rather than a pointer ?

2nd, if I try to access that array (member of struct), e.g. lets say I
pass it to function, then it will still be passed as pointer.
 
A

arnuld

..SNIP...
Your linked list logic seems a little strange (to me): your empty linked
list starts with a dummy node containing empty key/value pairs. Normally
you'd start with a NULL root (baseEelement) which subsequently points to the
first element which is added.


If the root is NULL, how am I supposed to use "root->next = p" ?
 

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

Similar Threads


Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top