Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #163221 > unrolled thread

on ``vector'' and ``array''

Started byMeredith Montgomery <mmontgomery@levado.to>
First post2021-10-29 01:00 -0300
Last post2021-10-29 11:08 -0700
Articles 12 — 5 participants

Back to article view | Back to comp.lang.c


Contents

  on ``vector'' and ``array'' Meredith Montgomery <mmontgomery@levado.to> - 2021-10-29 01:00 -0300
    Re: on ``vector'' and ``array'' Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-10-28 21:29 -0700
    Re: on ``vector'' and ``array'' Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2021-10-29 04:42 -0700
      Re: on ``vector'' and ``array'' Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-10-29 14:02 +0100
        Re: on ``vector'' and ``array'' Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2021-10-29 06:58 -0700
          Re: on ``vector'' and ``array'' Meredith Montgomery <mmontgomery@levado.to> - 2021-10-29 12:02 -0300
            Re: on ``vector'' and ``array'' Anand Hariharan <mailto.anand.hariharan@gmail.com> - 2021-10-30 09:33 -0700
              Re: on ``vector'' and ``array'' Meredith Montgomery <mmontgomery@levado.to> - 2021-10-30 15:29 -0300
              Re: on ``vector'' and ``array'' Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2021-10-30 13:25 -0700
                Re: on ``vector'' and ``array'' Meredith Montgomery <mmontgomery@levado.to> - 2021-10-31 12:02 -0300
          Re: on ``vector'' and ``array'' Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-10-29 16:38 +0100
      Re: on ``vector'' and ``array'' Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-10-29 11:08 -0700

#163221 — on ``vector'' and ``array''

FromMeredith Montgomery <mmontgomery@levado.to>
Date2021-10-29 01:00 -0300
Subjecton ``vector'' and ``array''
Message-ID<8635oklbti.fsf@levado.to>
I never call an array a vector because C89 doesn't even mention the word
vector in there, but C99 does in a silly example in section 6.7.3.  What
is your choice of terminology?  (What is an array?  What is a vector?)

(*) C99 section 6.7.3

--8<---------------cut here---------------start------------->8---
[...] For example, this permits new_vector to return a vector.

typedef struct { int n; float * restrict v; } vector;
vector new_vector(int n)
{
  vector t;
  t.n = n;
  t.v = malloc(n * sizeof (float));
  return t;
}
--8<---------------cut here---------------end--------------->8---

Look at this example.  They're really building a convenient data
structure there.  But is it well-named?

Vectors (to me) belong to a vector space and vector spaces have
well-defined dimensions.

[toc] | [next] | [standalone]


#163223

FromKeith Thompson <Keith.S.Thompson+u@gmail.com>
Date2021-10-28 21:29 -0700
Message-ID<87y26czc5u.fsf@nosuchdomain.example.com>
In reply to#163221
Meredith Montgomery <mmontgomery@levado.to> writes:
> I never call an array a vector because C89 doesn't even mention the word
> vector in there, but C99 does in a silly example in section 6.7.3.  What
> is your choice of terminology?  (What is an array?  What is a vector?)
>
> (*) C99 section 6.7.3
>
> --8<---------------cut here---------------start------------->8---
> [...] For example, this permits new_vector to return a vector.
>
> typedef struct { int n; float * restrict v; } vector;
> vector new_vector(int n)
> {
>   vector t;
>   t.n = n;
>   t.v = malloc(n * sizeof (float));
>   return t;
> }
> --8<---------------cut here---------------end--------------->8---
>
> Look at this example.  They're really building a convenient data
> structure there.  But is it well-named?
>
> Vectors (to me) belong to a vector space and vector spaces have
> well-defined dimensions.

That doesn't call an array a vector.  It calls a particular structure a
vector, and just in a non-normative example.

It's common to refer to array-like data structures as "vectors".  See
C++'s std::vector, for example.

And in this case, a value of this type "vector" represents (to the
extent that float values represent real numbers) a mathematical vector
in an n-dimensional vector space, where the value of n the value passed
to new_vector.  (The number of dimensions doesn't have to be a
constant.)

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

[toc] | [prev] | [next] | [standalone]


#163233

FromMalcolm McLean <malcolm.arthur.mclean@gmail.com>
Date2021-10-29 04:42 -0700
Message-ID<9288af47-3e78-4016-b5a6-519d44b560b6n@googlegroups.com>
In reply to#163221
On Friday, 29 October 2021 at 05:02:52 UTC+1, Meredith Montgomery wrote:
> I never call an array a vector because C89 doesn't even mention the word 
> vector in there, but C99 does in a silly example in section 6.7.3. What 
> is your choice of terminology? (What is an array? What is a vector?) 
> 
> (*) C99 section 6.7.3 
> 
> --8<---------------cut here---------------start------------->8--- 
> [...] For example, this permits new_vector to return a vector. 
> 
> typedef struct { int n; float * restrict v; } vector; 
> vector new_vector(int n) 
> { 
> vector t; 
> t.n = n; 
> t.v = malloc(n * sizeof (float)); 
> return t; 
> } 
> --8<---------------cut here---------------end--------------->8--- 
> 
> Look at this example. They're really building a convenient data 
> structure there. But is it well-named? 
> 
> Vectors (to me) belong to a vector space and vector spaces have 
> well-defined dimensions.
>
An array is an arrangement of data such that there are equal steps (in C,
in memory space, in other languages maybe in a logical index space) between
elements.
A vector is a collection of two or more scalars that define a point or direction
in a multi-dimensional space.

In C, the term "array" is slightly misused, to refer to the memory space rather
than the data within it. This is a bit like calling the parade ground the "array"
rather than the soldiers upon it.

In C++, the term "vector" is misused quite badly to refer to an array. That's because
early on in the development of the standard template library, the identifier "array"
was used for an inconvenient container that is seldom used, creating the need for
another name to use for the normal array type.

A "vector" is also something that carries communication (mosquitoes are vectors
for malaria). That's a different sense of the word.

[toc] | [prev] | [next] | [standalone]


#163236

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2021-10-29 14:02 +0100
Message-ID<87fsskugpt.fsf@bsb.me.uk>
In reply to#163233
Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:

> In C++, the term "vector" is misused quite badly to refer to an
> array. That's because early on in the development of the standard
> template library, the identifier "array" was used for an inconvenient
> container that is seldom used, creating the need for another name to
> use for the normal array type.

What was array used for in the early STL?  std::array is present in
recent versions of C++, but I don't know of the earlier usage.

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#163237

FromMalcolm McLean <malcolm.arthur.mclean@gmail.com>
Date2021-10-29 06:58 -0700
Message-ID<61ed0973-6096-415f-bd37-4d3881339cb6n@googlegroups.com>
In reply to#163236
On Friday, 29 October 2021 at 14:02:36 UTC+1, Ben Bacarisse wrote:
> Malcolm McLean <malcolm.ar...@gmail.com> writes: 
> 
> > In C++, the term "vector" is misused quite badly to refer to an 
> > array. That's because early on in the development of the standard 
> > template library, the identifier "array" was used for an inconvenient 
> > container that is seldom used, creating the need for another name to 
> > use for the normal array type.
> What was array used for in the early STL? std::array is present in 
> recent versions of C++, but I don't know of the earlier usage. 
> 
I've checked and it appears I was wrong. The inconvenient type was "valarray"
(an array constrained to hold scalars). "array" was avoided because of the use 
of the term in the C standard.
However Alex Stepanov (the man responsible for the STL) later said he had
made a mistake by choosing the identifier "vector".

[toc] | [prev] | [next] | [standalone]


#163241

FromMeredith Montgomery <mmontgomery@levado.to>
Date2021-10-29 12:02 -0300
Message-ID<86bl37kh6m.fsf@levado.to>
In reply to#163237
Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:

> On Friday, 29 October 2021 at 14:02:36 UTC+1, Ben Bacarisse wrote:
>> Malcolm McLean <malcolm.ar...@gmail.com> writes: 
>> 
>> > In C++, the term "vector" is misused quite badly to refer to an 
>> > array. That's because early on in the development of the standard 
>> > template library, the identifier "array" was used for an
>> > inconvenient
>> > container that is seldom used, creating the need for another name to 
>> > use for the normal array type.
>> What was array used for in the early STL? std::array is present in 
>> recent versions of C++, but I don't know of the earlier usage. 
>> 
> I've checked and it appears I was wrong. The inconvenient type was
> "valarray"
> (an array constrained to hold scalars). "array" was avoided because of
> the use
> of the term in the C standard.
> However Alex Stepanov (the man responsible for the STL) later said he had
> made a mistake by choosing the identifier "vector".

Oh, nice.  Can you locate the reference?  I just searched every
interview of his from the interviews-section at

  http://stepanovpapers.com/

and did not find any comment to that effect.  Thank you!

[toc] | [prev] | [next] | [standalone]


#163269

FromAnand Hariharan <mailto.anand.hariharan@gmail.com>
Date2021-10-30 09:33 -0700
Message-ID<17050254-bc0d-4923-8c3d-494678ccca5dn@googlegroups.com>
In reply to#163241
On Friday, October 29, 2021 at 10:04:37 AM UTC-5, Meredith Montgomery wrote:
> Malcolm McLean <malcolm.ar...@gmail.com> writes: 
> 
> > On Friday, 29 October 2021 at 14:02:36 UTC+1, Ben Bacarisse wrote: 
> >> Malcolm McLean <malcolm.ar...@gmail.com> writes: 
> >> 
> >> > In C++, the term "vector" is misused quite badly to refer to an 
> >> > array. That's because early on in the development of the standard 
> >> > template library, the identifier "array" was used for an 
> >> > inconvenient 
> >> > container that is seldom used, creating the need for another name to 
> >> > use for the normal array type. 
> >> What was array used for in the early STL? std::array is present in 
> >> recent versions of C++, but I don't know of the earlier usage. 
> >> 
> > I've checked and it appears I was wrong. The inconvenient type was 
> > "valarray" 
> > (an array constrained to hold scalars). "array" was avoided because of 
> > the use 
> > of the term in the C standard. 
> > However Alex Stepanov (the man responsible for the STL) later said he had 
> > made a mistake by choosing the identifier "vector".
> Oh, nice. Can you locate the reference? I just searched every 
> interview of his from the interviews-section at 
> 
> http://stepanovpapers.com/ 
> 
> and did not find any comment to that effect. Thank you!

He talks about this some 7' into this ~1 hour long video:

https://www.youtube.com/watch?v=etZgaSjzqlU

Also Stroustrup (in TC++PL) says it has to do with how terminology evolved.

- Anand

[toc] | [prev] | [next] | [standalone]


#163272

FromMeredith Montgomery <mmontgomery@levado.to>
Date2021-10-30 15:29 -0300
Message-ID<868ryacqnb.fsf@levado.to>
In reply to#163269
Anand Hariharan <mailto.anand.hariharan@gmail.com> writes:

> On Friday, October 29, 2021 at 10:04:37 AM UTC-5, Meredith Montgomery wrote:
>> Malcolm McLean <malcolm.ar...@gmail.com> writes: 
>> 
>> > On Friday, 29 October 2021 at 14:02:36 UTC+1, Ben Bacarisse wrote: 
>> >> Malcolm McLean <malcolm.ar...@gmail.com> writes: 
>> >> 
>> >> > In C++, the term "vector" is misused quite badly to refer to an 
>> >> > array. That's because early on in the development of the standard 
>> >> > template library, the identifier "array" was used for an 
>> >> > inconvenient 
>> >> > container that is seldom used, creating the need for another name to 
>> >> > use for the normal array type. 
>> >> What was array used for in the early STL? std::array is present in 
>> >> recent versions of C++, but I don't know of the earlier usage. 
>> >> 
>> > I've checked and it appears I was wrong. The inconvenient type was 
>> > "valarray" 
>> > (an array constrained to hold scalars). "array" was avoided because of 
>> > the use 
>> > of the term in the C standard. 
>> > However Alex Stepanov (the man responsible for the STL) later said he had 
>> > made a mistake by choosing the identifier "vector".
>> Oh, nice. Can you locate the reference? I just searched every 
>> interview of his from the interviews-section at 
>> 
>> http://stepanovpapers.com/ 
>> 
>> and did not find any comment to that effect. Thank you!
>
> He talks about this some 7' into this ~1 hour long video:
>
> https://www.youtube.com/watch?v=etZgaSjzqlU

Nice.

  https://www.youtube.com/watch?v=etZgaSjzqlU&t=412s

> Also Stroustrup (in TC++PL) says it has to do with how terminology evolved.

Thank you so much!

[toc] | [prev] | [next] | [standalone]


#163274

FromMalcolm McLean <malcolm.arthur.mclean@gmail.com>
Date2021-10-30 13:25 -0700
Message-ID<65a20ab1-1436-453c-b01c-9b37c1a7cf9fn@googlegroups.com>
In reply to#163269
On Saturday, 30 October 2021 at 17:33:23 UTC+1, Anand Hariharan wrote:
> On Friday, October 29, 2021 at 10:04:37 AM UTC-5, Meredith Montgomery wrote: 
> > Malcolm McLean <malcolm.ar...@gmail.com> writes: 
> > 
> > > On Friday, 29 October 2021 at 14:02:36 UTC+1, Ben Bacarisse wrote: 
> > >> Malcolm McLean <malcolm.ar...@gmail.com> writes: 
> > >> 
> > >> > In C++, the term "vector" is misused quite badly to refer to an 
> > >> > array. That's because early on in the development of the standard 
> > >> > template library, the identifier "array" was used for an 
> > >> > inconvenient 
> > >> > container that is seldom used, creating the need for another name to 
> > >> > use for the normal array type. 
> > >> What was array used for in the early STL? std::array is present in 
> > >> recent versions of C++, but I don't know of the earlier usage. 
> > >> 
> > > I've checked and it appears I was wrong. The inconvenient type was 
> > > "valarray" 
> > > (an array constrained to hold scalars). "array" was avoided because of 
> > > the use 
> > > of the term in the C standard. 
> > > However Alex Stepanov (the man responsible for the STL) later said he had 
> > > made a mistake by choosing the identifier "vector". 
> > Oh, nice. Can you locate the reference? I just searched every 
> > interview of his from the interviews-section at 
> > 
> > http://stepanovpapers.com/ 
> > 
> > and did not find any comment to that effect. Thank you!
> He talks about this some 7' into this ~1 hour long video: 
> 
> https://www.youtube.com/watch?v=etZgaSjzqlU 
> 
Thanks. I found myself watching the whole thing.

[toc] | [prev] | [next] | [standalone]


#163275

FromMeredith Montgomery <mmontgomery@levado.to>
Date2021-10-31 12:02 -0300
Message-ID<86cznlb5ki.fsf@levado.to>
In reply to#163274
Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:

> On Saturday, 30 October 2021 at 17:33:23 UTC+1, Anand Hariharan wrote:
>> On Friday, October 29, 2021 at 10:04:37 AM UTC-5, Meredith Montgomery wrote: 
>> > Malcolm McLean <malcolm.ar...@gmail.com> writes: 
>> > 
>> > > On Friday, 29 October 2021 at 14:02:36 UTC+1, Ben Bacarisse wrote: 
>> > >> Malcolm McLean <malcolm.ar...@gmail.com> writes: 
>> > >> 
>> > >> > In C++, the term "vector" is misused quite badly to refer to an 
>> > >> > array. That's because early on in the development of the standard 
>> > >> > template library, the identifier "array" was used for an 
>> > >> > inconvenient 
>> > >> > container that is seldom used, creating the need for another name to 
>> > >> > use for the normal array type. 
>> > >> What was array used for in the early STL? std::array is present in 
>> > >> recent versions of C++, but I don't know of the earlier usage. 
>> > >> 
>> > > I've checked and it appears I was wrong. The inconvenient type was 
>> > > "valarray" 
>> > > (an array constrained to hold scalars). "array" was avoided because of 
>> > > the use 
>> > > of the term in the C standard. 
>> > > However Alex Stepanov (the man responsible for the STL) later said he had 
>> > > made a mistake by choosing the identifier "vector". 
>> > Oh, nice. Can you locate the reference? I just searched every 
>> > interview of his from the interviews-section at 
>> > 
>> > http://stepanovpapers.com/ 
>> > 
>> > and did not find any comment to that effect. Thank you!
>> He talks about this some 7' into this ~1 hour long video: 
>> 
>> https://www.youtube.com/watch?v=etZgaSjzqlU 
>> 
> Thanks. I found myself watching the whole thing.

The lecture is indeed really nice.  I had a lot of fun at time 7:07:

  -- Which class would you use?
  -- VECTAR!
  -- Vectar, guys.
  -- You use Vectar.

[toc] | [prev] | [next] | [standalone]


#163243

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2021-10-29 16:38 +0100
Message-ID<87a6irvo1a.fsf@bsb.me.uk>
In reply to#163237
Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:

> On Friday, 29 October 2021 at 14:02:36 UTC+1, Ben Bacarisse wrote:
>> Malcolm McLean <malcolm.ar...@gmail.com> writes: 
>> 
>> > In C++, the term "vector" is misused quite badly to refer to an 
>> > array. That's because early on in the development of the standard 
>> > template library, the identifier "array" was used for an inconvenient 
>> > container that is seldom used, creating the need for another name to 
>> > use for the normal array type.
>> What was array used for in the early STL? std::array is present in 
>> recent versions of C++, but I don't know of the earlier usage. 
>> 
> I've checked and it appears I was wrong. The inconvenient type was "valarray"
> (an array constrained to hold scalars). "array" was avoided because of the use 
> of the term in the C standard.

Ah.  I followed C++ development from the start (pre-STL) but then moved
on to other things only to come back when the STL was largely fully
formed. 

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#163247

FromKeith Thompson <Keith.S.Thompson+u@gmail.com>
Date2021-10-29 11:08 -0700
Message-ID<87pmrnzot0.fsf@nosuchdomain.example.com>
In reply to#163233
Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:
[...]
> In C, the term "array" is slightly misused, to refer to the memory
> space rather than the data within it. This is a bit like calling the
> parade ground the "array" rather than the soldiers upon it.
[...]

This problem, if it were one, could be avoided by thinking of the word
"array" as an adjective, not a noun.  We can have array types, array
values, array objects, array expressions, but never just "an array"
(though we can call something an array informally).  Likewise for
"pointer".

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.c


csiph-web