From: Ben Bacarisse on
ram(a)zedat.fu-berlin.de (Stefan Ram) writes:

> Nicolas George <nicolas$george(a)salle-s.org> writes:
>>And why does everyone write "array[index]" instead of "index[array]"?
>
> Not everyone does so.

That is true of almost everything, no matter how reasonable the
behaviour in question is!

> »index[ array ]« actually is very natural as it is like what
> mathematicians call a »projection«, for example to get the
> coordinate 1 of the point x =( x¹, x², x³ ), one uses the
> projection »p¹«, thus x¹ = p¹( x ), where x¹ is the coordinate
> 1 of x.

This would be a stronger argument if the mathematicians did not put
the projection index after both the vector name and the letter
denoting the projection function. That aside, the result looks like
1[x] but in fact it is not. The notation the mathematicians end up
with is that of a function, and it is rare for p(x) to be equal to
x(p) in mathematics.

Yes, I really do get your point that 1[x] looks like the projection of
x, but my point is that when mathematicians want a notation for that
the result is something (a function application) that does not commute
like [] in C. In other words, your example cuts both ways.

I don't think a mathematician, writing projections, would be any
happier with 1[x] than with x[1].

> »f( x )« can be written »p( x )( f )« as well, where p( x )
> is a »functional« assigning to every function f its value
> at the point x.
>
> Most people use »array[ index ]« just because they know more
> languages than just C, and most other languages only allow
> this.

Hmm... I know more languages than just C; but I also know that, in C,
a[1] == 1[a] and yet I don't write the latter (except as an example of
the equivalence). Am I just pandering to other people's ignorance? I
don't think so.

How do you feel about i[array][j] and j[i[array]] (or, indeed,
j[array[i]] to get the full set)?

--
Ben.
From: Ben Bacarisse on
lacos(a)ludens.elte.hu (Ersek, Laszlo) writes:

> In article <OIidndrfAtccKg3WnZ2dnUVZ8sCdnZ2d(a)bt.com>,
> Richard Heathfield <rjh(a)see.sig.invalid> writes:
>
>> Seebs wrote:
<snip>
>>> Consider:
>>> for (i = 0; i < 10; ++i)
>>>
>>> Why do we write "i < 10" rather than "10 >= i"?
>>
>> Good question.
>
> ... It's either me, or now two of you not noticing (or ignoring) that
> "10 == i" satisfies the second but not the first.

I assumed that the "good question" reply was intended to draw Seebs's
attention to that fact; otherwise I'd have pointed it out. Looking
at it now, with all of Richard's "why" questions, it seems possible
that the reply was not meant the way I assumed it was.

Either way, it's not really at the heart of the question unless you
think the switch *caused* the typo.

<snip>
--
Ben.
From: Richard Heathfield on
Ersek, Laszlo wrote:
> In article <OIidndrfAtccKg3WnZ2dnUVZ8sCdnZ2d(a)bt.com>,
> Richard Heathfield <rjh(a)see.sig.invalid> writes:
>
>> Seebs wrote:
>>
>> <snip>
>>
>>> When I see "if (x != y)" in C, I
>>> unconsciously perceive it to be the case that x could vary and y couldn't.
>> Why?
>
> Because he pronounces it as "x is not equal to y", and the subject of
> that sentence is "x". "x" is the actor, the variable that is acting. "y"
> is part of the prepositional phrase, it is static.

This is C we're discussing, not English. It is folly to pretend that the
rules of English apply to C.

>>> Consider:
>>> for (i = 0; i < 10; ++i)
>>>
>>> Why do we write "i < 10" rather than "10 >= i"?
>> Good question.
>
> .... It's either me, or now two of you not noticing (or ignoring) that
> "10 == i" satisfies the second but not the first.

Ignoring. Probably a minor thinko on his part, no big deal.

>>> Because i's the one that
>>> varies, so "i is less than ten" is more idiomatic than "ten is greater than
>>> or equal to i".
>> Why?
>
> Because programmatically, "i" changes over time, 10 does not,

That doesn't answer the question.

> and when
> one reads out loud the controlling expression in English, the subject of
> that sentence ("the actor") should be the entity that is acting.

Again, this is C we're discussing, not English.

>>> Now consider:
>>> for (i = 0; i < max; ++i)
>>>
>>> even though "max" may vary over time, the assumption is that, for this loop,
>>> i changes and max doesn't.
>> Why?
>
> Because when read out loud, "i" is the subject.

Again, your comment would only be relevant if this were English, which
it isn't.

<snip>

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
"Usenet is a strange place" - dmr 29 July 1999
Sig line vacant - apply within
From: Nicolas George on
Richard Heathfield wrote in message
<4JydnbCdGNgatgzWnZ2dnUVZ7rydnZ2d(a)bt.com>:
> This is C we're discussing, not English. It is folly to pretend that the
> rules of English apply to C.

The rules of the human mind, made manifest by the structure of natural
languages, should apply to any artificial language if you want it to be
readable.
From: Ersek, Laszlo on
In article
<0.49be2e2b11253f6112d8.20100305151304GMT.87vddaajk0.fsf(a)bsb.me.uk>,
Ben Bacarisse <ben.usenet(a)bsb.me.uk> writes:

> lacos(a)ludens.elte.hu (Ersek, Laszlo) writes:
>

>> In article <OIidndrfAtccKg3WnZ2dnUVZ8sCdnZ2d(a)bt.com>,
>> Richard Heathfield <rjh(a)see.sig.invalid> writes:
>>

>>> Seebs wrote:

>>>> for (i = 0; i < 10; ++i)
>>>>
>>>> Why do we write "i < 10" rather than "10 >= i"?

>> "10 == i" satisfies the second but not the first.

> Either way, it's not really at the heart of the question unless you
> think the switch *caused* the typo.

Yes, I thought (and think) that that was not unpossible. If my memory
serves, both Keith and Seebs have pointed out that they need to reorder
reverse-ordered relational operators in their heads (sorry if I'm making
this up now) or that it causes extra mental load or something to that
effect. So the typo may be related to the reversing process.

Cheers,
lacos
First  |  Prev  |  Next  |  Last
Pages: 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
Prev: integer
Next: shared memory question