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


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

Dinamic array without malloc - Can be done?

Started by"Fernando D. Bozzo" <fdbozzo@gmail.com>
First post2017-01-15 08:45 -0800
Last post2017-01-30 05:21 -0800
Articles 20 on this page of 151 — 22 participants

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


Contents

  Dinamic array without malloc - Can be done? "Fernando D. Bozzo" <fdbozzo@gmail.com> - 2017-01-15 08:45 -0800
    Re: Dinamic array without malloc - Can be done? BartC <bc@freeuk.com> - 2017-01-15 16:53 +0000
      Re: Dinamic array without malloc - Can be done? fir <profesor.fir@gmail.com> - 2017-01-15 09:34 -0800
        Re: Dinamic array without malloc - Can be done? BartC <bc@freeuk.com> - 2017-01-17 21:09 +0000
          Re: Dinamic array without malloc - Can be done? fir <profesor.fir@gmail.com> - 2017-01-17 13:45 -0800
            Re: Dinamic array without malloc - Can be done? fir <profesor.fir@gmail.com> - 2017-01-17 14:09 -0800
            Re: Dinamic array without malloc - Can be done? BartC <bc@freeuk.com> - 2017-01-17 22:41 +0000
            Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-17 15:06 -0800
              Re: Dinamic array without malloc - Can be done? fir <profesor.fir@gmail.com> - 2017-01-17 16:49 -0800
              Re: Dinamic array without malloc - Can be done? Keith Thompson <kst-u@mib.org> - 2017-01-17 16:56 -0800
                Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-17 20:37 -0800
                  Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-18 09:38 +0100
                  Re: Dinamic array without malloc - Can be done? Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-31 08:49 -0800
                    Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-31 10:39 -0800
                      Re: Dinamic array without malloc - Can be done? luser droog <luser.droog@gmail.com> - 2017-01-31 10:55 -0800
                        Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-31 11:40 -0800
                      Re: Dinamic array without malloc - Can be done? "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-01-31 10:57 -0800
                      Re: Dinamic array without malloc - Can be done? Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-03 23:06 -0800
      Re: Dinamic array without malloc - Can be done? "Fernando D. Bozzo" <fdbozzo@gmail.com> - 2017-01-15 10:42 -0800
        Re: Dinamic array without malloc - Can be done? BartC <bc@freeuk.com> - 2017-01-15 20:15 +0000
          Re: Dinamic array without malloc - Can be done? Keith Thompson <kst-u@mib.org> - 2017-01-15 12:43 -0800
          Re: Dinamic array without malloc - Can be done? "Fernando D. Bozzo" <fdbozzo@gmail.com> - 2017-01-15 15:08 -0800
    Re: Dinamic array without malloc - Can be done? "James R. Kuyper" <jameskuyper@verizon.net> - 2017-01-15 12:25 -0500
      Re: Dinamic array without malloc - Can be done? "Fernando D. Bozzo" <fdbozzo@gmail.com> - 2017-01-15 10:46 -0800
        Re: Dinamic array without malloc - Can be done? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-15 20:13 +0000
          Re: Dinamic array without malloc - Can be done? "Fernando D. Bozzo" <fdbozzo@gmail.com> - 2017-01-15 15:06 -0800
      Re: Dinamic array without malloc - Can be done? Keith Thompson <kst-u@mib.org> - 2017-01-15 12:46 -0800
        Re: Dinamic array without malloc - Can be done? "James R. Kuyper" <jameskuyper@verizon.net> - 2017-01-15 16:10 -0500
        Re: Dinamic array without malloc - Can be done? Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-15 20:37 -0800
          Re: Dinamic array without malloc - Can be done? Keith Thompson <kst-u@mib.org> - 2017-01-15 21:02 -0800
            Re: Dinamic array without malloc - Can be done? Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-30 04:23 -0800
          Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-16 09:05 +0100
            Re: Dinamic array without malloc - Can be done? Ian Collins <ian-news@hotmail.com> - 2017-01-16 21:16 +1300
              Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-16 09:48 +0100
    Re: Dinamic array without malloc - Can be done? fir <profesor.fir@gmail.com> - 2017-01-15 09:29 -0800
      Re: Dinamic array without malloc - Can be done? fir <profesor.fir@gmail.com> - 2017-01-15 09:37 -0800
      Re: Dinamic array without malloc - Can be done? fir <profesor.fir@gmail.com> - 2017-01-15 09:56 -0800
        Re: Dinamic array without malloc - Can be done? fir <profesor.fir@gmail.com> - 2017-01-15 10:34 -0800
      Re: Dinamic array without malloc - Can be done? "Fernando D. Bozzo" <fdbozzo@gmail.com> - 2017-01-15 10:48 -0800
        Re: Dinamic array without malloc - Can be done? fir <profesor.fir@gmail.com> - 2017-01-15 11:10 -0800
        Re: Dinamic array without malloc - Can be done? Jean-Marc Bourguet <jm@bourguet.org> - 2017-01-15 20:22 +0100
          Re: Dinamic array without malloc - Can be done? Chad <cdalten@gmail.com> - 2017-01-15 11:50 -0800
          Re: Dinamic array without malloc - Can be done? "Fernando D. Bozzo" <fdbozzo@gmail.com> - 2017-01-15 15:12 -0800
    Re: Dinamic array without malloc - Can be done? Richard Heathfield <rjh@cpax.org.uk> - 2017-01-15 17:50 +0000
      Re: Dinamic array without malloc - Can be done? "Fernando D. Bozzo" <fdbozzo@gmail.com> - 2017-01-15 10:38 -0800
        Re: Dinamic array without malloc - Can be done? Richard Heathfield <rjh@cpax.org.uk> - 2017-01-15 19:34 +0000
          Re: Dinamic array without malloc - Can be done? Keith Thompson <kst-u@mib.org> - 2017-01-15 12:51 -0800
            Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-15 13:10 -0800
              Re: Dinamic array without malloc - Can be done? Keith Thompson <kst-u@mib.org> - 2017-01-15 16:23 -0800
                Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-15 18:08 -0800
              Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-16 09:56 +0100
                Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-16 08:35 -0800
                  Re: Dinamic array without malloc - Can be done? "Chris M. Thomasson" <invalid@invalid.invalid> - 2017-01-16 11:07 -0800
                    Re: Dinamic array without malloc - Can be done? "Chris M. Thomasson" <invalid@invalid.invalid> - 2017-01-16 11:17 -0800
                      Re: Dinamic array without malloc - Can be done? Robert Wessel <robertwessel2@yahoo.com> - 2017-01-16 15:21 -0600
                        Re: Dinamic array without malloc - Can be done? "Chris M. Thomasson" <invalid@invalid.invalid> - 2017-01-31 22:22 -0800
                  Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-17 00:22 +0100
                    Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-16 16:23 -0800
                      Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-17 02:04 +0100
                        Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-16 17:27 -0800
                          Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-17 09:16 +0100
            Re: Dinamic array without malloc - Can be done? Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-15 20:32 -0800
            Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-16 10:02 +0100
              Re: Dinamic array without malloc - Can be done? Keith Thompson <kst-u@mib.org> - 2017-01-16 09:22 -0800
                Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-17 00:25 +0100
        Re: Dinamic array without malloc - Can be done? Barry Schwarz <schwarzb@dqel.com> - 2017-01-15 11:53 -0800
          Re: Dinamic array without malloc - Can be done? fir <profesor.fir@gmail.com> - 2017-01-15 12:22 -0800
          Re: Dinamic array without malloc - Can be done? "Fernando D. Bozzo" <fdbozzo@gmail.com> - 2017-01-15 15:32 -0800
            Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-15 16:01 -0800
              Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-16 10:19 +0100
                Re: Dinamic array without malloc - Can be done? BartC <bc@freeuk.com> - 2017-01-16 11:28 +0000
                  Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-16 14:29 +0100
                    Re: Dinamic array without malloc - Can be done? BartC <bc@freeuk.com> - 2017-01-16 15:41 +0000
                      Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-16 17:27 +0100
                    Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-16 07:56 -0800
                      Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-16 17:31 +0100
                        Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-16 08:48 -0800
                          Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-17 00:29 +0100
                  Re: Dinamic array without malloc - Can be done? "Chris M. Thomasson" <invalid@invalid.invalid> - 2017-01-16 11:25 -0800
                    Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-16 12:28 -0800
                      Re: Dinamic array without malloc - Can be done? "Chris M. Thomasson" <invalid@invalid.invalid> - 2017-01-16 12:38 -0800
            Re: Dinamic array without malloc - Can be done? Keith Thompson <kst-u@mib.org> - 2017-01-15 16:57 -0800
              Re: Dinamic array without malloc - Can be done? "Fernando D. Bozzo" <fdbozzo@gmail.com> - 2017-01-16 00:37 -0800
                Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-16 10:23 +0100
                  Re: Dinamic array without malloc - Can be done? "Fernando D. Bozzo" <fdbozzo@gmail.com> - 2017-01-16 01:35 -0800
                    Re: Dinamic array without malloc - Can be done? Keith Thompson <kst-u@mib.org> - 2017-01-16 09:15 -0800
            Re: Dinamic array without malloc - Can be done? BartC <bc@freeuk.com> - 2017-01-16 01:29 +0000
          Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-16 10:08 +0100
            Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-16 08:08 -0800
              Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-17 00:35 +0100
                Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-16 16:31 -0800
                  Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-17 09:27 +0100
                    Re: Dinamic array without malloc - Can be done? BartC <bc@freeuk.com> - 2017-01-17 12:11 +0000
                      Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-17 14:23 +0100
                      Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-17 05:38 -0800
                        Re: Dinamic array without malloc - Can be done? BartC <bc@freeuk.com> - 2017-01-17 14:17 +0000
                          Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-17 07:09 -0800
                    Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-17 05:14 -0800
                      Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-17 14:40 +0100
                        Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-17 06:41 -0800
                          Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-17 16:00 +0100
                            Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-17 07:45 -0800
                              Re: Dinamic array without malloc - Can be done? fir <profesor.fir@gmail.com> - 2017-01-17 08:18 -0800
                                Re: Dinamic array without malloc - Can be done? fir <profesor.fir@gmail.com> - 2017-01-17 08:27 -0800
                                  Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-17 09:29 -0800
                                Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-17 09:23 -0800
                                  Re: Dinamic array without malloc - Can be done? fir <profesor.fir@gmail.com> - 2017-01-17 10:35 -0800
                                    Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-17 12:41 -0800
                                      Re: Dinamic array without malloc - Can be done? fir <profesor.fir@gmail.com> - 2017-01-17 13:45 -0800
                            Re: Dinamic array without malloc - Can be done? Robert Wessel <robertwessel2@yahoo.com> - 2017-01-17 21:00 -0600
        Re: Dinamic array without malloc - Can be done? fir <profesor.fir@gmail.com> - 2017-01-15 11:55 -0800
        Re: Dinamic array without malloc - Can be done? Siri Cruise <chine.bleu@yahoo.com> - 2017-01-15 14:59 -0800
      Re: Dinamic array without malloc - Can be done? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-15 20:04 +0000
        Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-15 21:33 +0100
          Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-15 13:00 -0800
            Re: Dinamic array without malloc - Can be done? Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-15 20:27 -0800
          Re: Dinamic array without malloc - Can be done? "James R. Kuyper" <jameskuyper@verizon.net> - 2017-01-15 16:34 -0500
            Re: Dinamic array without malloc - Can be done? "James R. Kuyper" <jameskuyper@verizon.net> - 2017-01-15 16:43 -0500
              Re: Dinamic array without malloc - Can be done? Keith Thompson <kst-u@mib.org> - 2017-01-15 16:17 -0800
                Re: Dinamic array without malloc - Can be done? Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-15 20:22 -0800
                  Re: Dinamic array without malloc - Can be done? Keith Thompson <kst-u@mib.org> - 2017-01-15 21:00 -0800
                    Re: Dinamic array without malloc - Can be done? Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-30 05:01 -0800
                      Re: Dinamic array without malloc - Can be done? Keith Thompson <kst-u@mib.org> - 2017-01-30 11:35 -0800
                        Re: Dinamic array without malloc - Can be done? Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-01 16:18 -0800
                          Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-02-01 16:37 -0800
                            Re: Dinamic array without malloc - Can be done? Robert Wessel <robertwessel2@yahoo.com> - 2017-02-01 23:21 -0600
                            Re: Dinamic array without malloc - Can be done? Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-02 00:27 -0800
                              Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-02-02 10:58 -0800
                                Re: Dinamic array without malloc - Can be done? Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-03 22:51 -0800
    Re: Dinamic array without malloc - Can be done? "Chris M. Thomasson" <invalid@invalid.invalid> - 2017-01-15 15:41 -0800
      Re: Dinamic array without malloc - Can be done? "Fernando D. Bozzo" <fdbozzo@gmail.com> - 2017-01-15 15:44 -0800
        Re: Dinamic array without malloc - Can be done? "Chris M. Thomasson" <invalid@invalid.invalid> - 2017-01-15 16:17 -0800
    Re: Dinamic array without malloc - Can be done? Alla _ <modelling.data@gmail.com> - 2017-01-16 01:47 -0800
      Re: Dinamic array without malloc - Can be done? "Fernando D. Bozzo" <fdbozzo@gmail.com> - 2017-01-16 01:50 -0800
        Re: Dinamic array without malloc - Can be done? Alla _ <modelling.data@gmail.com> - 2017-01-16 02:38 -0800
          Re: Dinamic array without malloc - Can be done? "Fernando D. Bozzo" <fdbozzo@gmail.com> - 2017-01-16 03:15 -0800
            Re: Dinamic array without malloc - Can be done? Alla _ <modelling.data@gmail.com> - 2017-01-16 03:40 -0800
              Re: Dinamic array without malloc - Can be done? "Fernando D. Bozzo" <fdbozzo@gmail.com> - 2017-01-16 04:21 -0800
            Re: Dinamic array without malloc - Can be done? Alla _ <modelling.data@gmail.com> - 2017-01-16 04:29 -0800
              Re: Dinamic array without malloc - Can be done? "Fernando D. Bozzo" <fdbozzo@gmail.com> - 2017-01-16 04:36 -0800
      Re: Dinamic array without malloc - Can be done? Richard Heathfield <rjh@cpax.org.uk> - 2017-01-16 11:36 +0000
        Re: Dinamic array without malloc - Can be done? Alla _ <modelling.data@gmail.com> - 2017-01-16 03:44 -0800
        Re: Dinamic array without malloc - Can be done? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-16 15:34 +0000
          Re: Dinamic array without malloc - Can be done? Richard Heathfield <rjh@cpax.org.uk> - 2017-01-16 16:01 +0000
    Re: Dinamic array without malloc - Can be done? John Bode <jfbode1029@gmail.com> - 2017-01-17 10:14 -0800
      Re: Dinamic array without malloc - Can be done? James Kuyper <jameskuyper@verizon.net> - 2017-01-17 13:21 -0500
        Re: Dinamic array without malloc - Can be done? John Bode <jfbode1029@gmail.com> - 2017-01-17 11:43 -0800
          Re: Dinamic array without malloc - Can be done? James Kuyper <jameskuyper@verizon.net> - 2017-01-17 15:07 -0500
        Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-17 12:24 -0800
      Re: Dinamic array without malloc - Can be done? "Fernando D. Bozzo" <fdbozzo@gmail.com> - 2017-01-17 10:24 -0800
      Re: Dinamic array without malloc - Can be done? Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-30 05:21 -0800

Page 7 of 8 — ← Prev page 1 2 3 4 5 6 [7] 8  Next page →


#101915

FromKeith Thompson <kst-u@mib.org>
Date2017-01-15 21:00 -0800
Message-ID<lno9z7fvl4.fsf@kst-u.example.com>
In reply to#101910
Tim Rentsch <txr@alumni.caltech.edu> writes:
> Keith Thompson <kst-u@mib.org> writes:
>> In C99, complex types are mandatory, but the <complex.h> header
>> is required only for hosted implementations.  That meant that a
>> freestanding implementation must support the types _Complex
>> float, _Complex double, and _Complex long double, but without
>> <complex.h> there's no portable way to specify the value of i.
>
> What isn't portable about this?
>
>     typedef _Complex float Zfloat;
>
>     Zfloat
>     imaginary_unit(){
>         return  (union {float f[2]; Zfloat z;}){ {0,1} }.z;
>     }

OK, no *clean* portable way.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

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


#102749

FromTim Rentsch <txr@alumni.caltech.edu>
Date2017-01-30 05:01 -0800
Message-ID<kfninowhfbk.fsf@x-alumni2.alumni.caltech.edu>
In reply to#101915
Keith Thompson <kst-u@mib.org> writes:

> Tim Rentsch <txr@alumni.caltech.edu> writes:
>> Keith Thompson <kst-u@mib.org> writes:
>>> In C99, complex types are mandatory, but the <complex.h> header
>>> is required only for hosted implementations.  That meant that a
>>> freestanding implementation must support the types _Complex
>>> float, _Complex double, and _Complex long double, but without
>>> <complex.h> there's no portable way to specify the value of i.
>>
>> What isn't portable about this?
>>
>>     typedef _Complex float Zfloat;
>>
>>     Zfloat
>>     imaginary_unit(){
>>         return  (union {float f[2];  Zfloat z;}){ {0,1} }.z;
>>     }
>
> OK, no *clean* portable way.

I'm not sure if this response is meant to be funny, but if it
isn't, what isn't clean about this way of providing i?  It can't
be used to initialize file scope or static varibles, but other
than that what's wrong with it?  (I'm assuming the function would
be defined as 'static inline' if that were thought important.)

Note by the way that freestanding implementations are not obliged
to support complex types, even in C99, by virtue of section 4 p6.

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


#102784

FromKeith Thompson <kst-u@mib.org>
Date2017-01-30 11:35 -0800
Message-ID<ln60kwbasv.fsf@kst-u.example.com>
In reply to#102749
Tim Rentsch <txr@alumni.caltech.edu> writes:
> Keith Thompson <kst-u@mib.org> writes:
>> Tim Rentsch <txr@alumni.caltech.edu> writes:
>>> Keith Thompson <kst-u@mib.org> writes:
>>>> In C99, complex types are mandatory, but the <complex.h> header
>>>> is required only for hosted implementations.  That meant that a
>>>> freestanding implementation must support the types _Complex
>>>> float, _Complex double, and _Complex long double, but without
>>>> <complex.h> there's no portable way to specify the value of i.
>>>
>>> What isn't portable about this?
>>>
>>>     typedef _Complex float Zfloat;
>>>
>>>     Zfloat
>>>     imaginary_unit(){
>>>         return  (union {float f[2];  Zfloat z;}){ {0,1} }.z;
>>>     }
>>
>> OK, no *clean* portable way.
>
> I'm not sure if this response is meant to be funny, but if it
> isn't, what isn't clean about this way of providing i?  It can't
> be used to initialize file scope or static varibles, but other
> than that what's wrong with it?  (I'm assuming the function would
> be defined as 'static inline' if that were thought important.)

The language provides complex types, but the core language
doesn't provide a direct way to specify the value of i, the most
fundamental mathematical complex constant that isn't a real number.
A function that takes advantage of an incidental guarantee about
the *representation* of complex types to construct the value of i
is clever and useful, but IMHO it's hardly clean.  (Perhaps that
guarantee is intended to permit this kind of thing.)

IMHO the language *should* have provided a simpler way to specify
the value of i.  Perhaps the semantics of compound literals could
have been extended to permit complex values, such as

    (float _Complex){0.0, 1.0};

Imagine a language that provides floating-point types but has no
way to write a constant expression with the value -1.0.  Some kind
of union hack that fiddles with the sign bit might be workable,
but I'd hardly consider it satisfactory.

> Note by the way that freestanding implementations are not obliged
> to support complex types, even in C99, by virtue of section 4 p6.

Ah, you're right, I missed that.  That blows most of my argument
out of the water.  Any C99 conforming hosted implementation (and
any C11 conforming hosted implementation that doesn't predefine
__STDC_NO_COMPLEX__) must support both the _Complex keyword and
the _Complex_I macro, so it's not as bad as I thought it was.
I suppose my remaining objection is mainly esthetic.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

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


#102937

FromTim Rentsch <txr@alumni.caltech.edu>
Date2017-02-01 16:18 -0800
Message-ID<kfna8a5cuns.fsf@x-alumni2.alumni.caltech.edu>
In reply to#102784
Keith Thompson <kst-u@mib.org> writes:

> Tim Rentsch <txr@alumni.caltech.edu> writes:
>> Keith Thompson <kst-u@mib.org> writes:
>>> Tim Rentsch <txr@alumni.caltech.edu> writes:
>>>> Keith Thompson <kst-u@mib.org> writes:
>>>>> In C99, complex types are mandatory, but the <complex.h> header
>>>>> is required only for hosted implementations.  That meant that a
>>>>> freestanding implementation must support the types _Complex
>>>>> float, _Complex double, and _Complex long double, but without
>>>>> <complex.h> there's no portable way to specify the value of i.
>>>>
>>>> What isn't portable about this?
>>>>
>>>>     typedef _Complex float Zfloat;
>>>>
>>>>     Zfloat
>>>>     imaginary_unit(){
>>>>         return  (union {float f[2];  Zfloat z;}){ {0,1} }.z;
>>>>     }
>>>
>>> OK, no *clean* portable way.
>>
>> I'm not sure if this response is meant to be funny, but if it
>> isn't, what isn't clean about this way of providing i?  It can't
>> be used to initialize file scope or static varibles, but other
>> than that what's wrong with it?  (I'm assuming the function would
>> be defined as 'static inline' if that were thought important.)
>
> The language provides complex types, but the core language
> doesn't provide a direct way to specify the value of i, the most
> fundamental mathematical complex constant that isn't a real number.
> A function that takes advantage of an incidental guarantee about
> the *representation* of complex types to construct the value of i
> is clever and useful, but IMHO it's hardly clean.  (Perhaps that
> guarantee is intended to permit this kind of thing.)

My reaction is different.  First I don't think the guarantee was
incidental:  I believe it was put in deliberately precisely to
allow this sort of representational access and manipulation.
Second, to me this way of providing i deserves being called
clean.  I agree that it isn't very pretty, but it is clean, in
the sense that it doesn't have any rough edges - it does the
job it was meant to do, without any strange corner cases or
bizarre constructions.

> IMHO the language *should* have provided a simpler way to specify
> the value of i.  [...]

Yes, that would have been better.  My comments though were
not about that.

> Imagine a language that provides floating-point types but has no
> way to write a constant expression with the value -1.0.  Some kind
> of union hack that fiddles with the sign bit might be workable,
> but I'd hardly consider it satisfactory.

The union technique for producing i is not what I would call a
hack, resting as it does on ordinary constructions and completely
portable guarantees made by the Standard.  So this analogy strikes
me as a little bit off.  More important though, it seems like your
complaint is one about the language.  My comments were never meant
to address how the language is defined or how good or bad it is;
they are meant only to offer a solution to problem, taking as
given the language as it has been defined already.

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


#102938

Fromsupercat@casperkitty.com
Date2017-02-01 16:37 -0800
Message-ID<440402f4-1645-4878-aef0-c8fa90ffd887@googlegroups.com>
In reply to#102937
On Wednesday, February 1, 2017 at 6:18:22 PM UTC-6, Tim Rentsch wrote:
> The union technique for producing i is not what I would call a
> hack, resting as it does on ordinary constructions and completely
> portable guarantees made by the Standard.  So this analogy strikes
> me as a little bit off.  More important though, it seems like your
> complaint is one about the language.  My comments were never meant
> to address how the language is defined or how good or bad it is;
> they are meant only to offer a solution to problem, taking as
> given the language as it has been defined already.

Even if C lacked floating-point literal constants, one could generate any
desired floating-point value by using integer constants, casting or coercing
them to floating-point types, and then performing arithmetic upon them.
Rendering some values accurately in the days before 64-bit integer types
would have been a nuisance, but it would hardly have been intractable, nor
would it have required using anything that isn't a core part of the language.

The union technique is hacky, and it should not be considered particularly
satisfactory, since among other things the value it returns is not a
compile-time constant.  While some compilers might be able to optimize it,
the level of complexity necessary to achieve such optimizations vastly
exceeds what would have been required to have an intrinsic with a reserved
name which would generate complex values.

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


#102945

FromRobert Wessel <robertwessel2@yahoo.com>
Date2017-02-01 23:21 -0600
Message-ID<n2g59c5che5kgkn0n8jmicbetdid0nuv1j@4ax.com>
In reply to#102938
On Wed, 1 Feb 2017 16:37:15 -0800 (PST), supercat@casperkitty.com
wrote:

>On Wednesday, February 1, 2017 at 6:18:22 PM UTC-6, Tim Rentsch wrote:
>> The union technique for producing i is not what I would call a
>> hack, resting as it does on ordinary constructions and completely
>> portable guarantees made by the Standard.  So this analogy strikes
>> me as a little bit off.  More important though, it seems like your
>> complaint is one about the language.  My comments were never meant
>> to address how the language is defined or how good or bad it is;
>> they are meant only to offer a solution to problem, taking as
>> given the language as it has been defined already.
>
>Even if C lacked floating-point literal constants, one could generate any
>desired floating-point value by using integer constants, casting or coercing
>them to floating-point types, and then performing arithmetic upon them.
>Rendering some values accurately in the days before 64-bit integer types
>would have been a nuisance, but it would hardly have been intractable, nor
>would it have required using anything that isn't a core part of the language.


While I think that's true for IEEE floats, you're going to have to be
a bit careful about rounding when parts are combined.

OTOH, there have been machines with much dirtier FP, and I'm not
convinced you could do it for every possible FP number on some of
those (I'm thinking specifically of the early Cray's here).  Or if you
could, it would have to be with a rather deep knowledge of how exactly
the internal operations curdle some of the low bits of the results.

In any event, it would likely not be doable in a portable way in any
event (since you'd need to understand at least the details of the
rounding operations).

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


#102950

FromTim Rentsch <txr@alumni.caltech.edu>
Date2017-02-02 00:27 -0800
Message-ID<kfnshnxatgm.fsf@x-alumni2.alumni.caltech.edu>
In reply to#102938
supercat@casperkitty.com writes:

> On Wednesday, February 1, 2017 at 6:18:22 PM UTC-6, Tim Rentsch wrote:
>> The union technique for producing i is not what I would call a
>> hack, resting as it does on ordinary constructions and completely
>> portable guarantees made by the Standard.  So this analogy strikes
>> me as a little bit off.  More important though, it seems like your
>> complaint is one about the language.  My comments were never meant
>> to address how the language is defined or how good or bad it is;
>> they are meant only to offer a solution to problem, taking as
>> given the language as it has been defined already.
>
> Even if C lacked floating-point literal constants, one could
> generate any desired floating-point value by using integer
> constants, casting or coercing them to floating-point types, and
> then performing arithmetic upon them.  [...]

Not in any way that is guaranteed to be portable.  The given
method (which you overzealously snipped, no surprise) for
generating i is guaranteed to be portable.

> The union technique [for producing i, presumably] is hacky, and it
> should not be considered particularly satisfactory,

It's true that it is not usable in contexts that require a
constant expression.  That doesn't make it a hack.  And just
because you don't like it doesn't mean it's not satisfactory - it
is perfectly satisfactory for its intended purpose.

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


#102973

Fromsupercat@casperkitty.com
Date2017-02-02 10:58 -0800
Message-ID<ce97b1b7-3e0c-48bf-bcc9-4b6531ab7031@googlegroups.com>
In reply to#102950
On Thursday, February 2, 2017 at 2:27:11 AM UTC-6, Tim Rentsch wrote:
> > Even if C lacked floating-point literal constants, one could
> > generate any desired floating-point value by using integer
> > constants, casting or coercing them to floating-point types, and
> > then performing arithmetic upon them.  [...]
> 
> Not in any way that is guaranteed to be portable.  The given
> method (which you overzealously snipped, no surprise) for
> generating i is guaranteed to be portable.

I don't think a portable decimal-to-floating-point conversion function that
is no less accurate than the C Standard would require compilers to be when
processing floating-point literals should be especially difficult.  The
only prerequisite for Kahan Summation to work is that it must be possible,
given a floating-point value, to force it to be rounded to a value of its
type.  It doesn't matter whether that rounding is accurate to 0.5ulp--merely
that the resulting value behave consistently.

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


#103121

FromTim Rentsch <txr@alumni.caltech.edu>
Date2017-02-03 22:51 -0800
Message-ID<kfnpoiya1of.fsf@x-alumni2.alumni.caltech.edu>
In reply to#102973
supercat@casperkitty.com writes:

> On Thursday, February 2, 2017 at 2:27:11 AM UTC-6, Tim Rentsch wrote:
>>> Even if C lacked floating-point literal constants, one could
>>> generate any desired floating-point value by using integer
>>> constants, casting or coercing them to floating-point types, and
>>> then performing arithmetic upon them.  [...]
>>
>> Not in any way that is guaranteed to be portable.  The given
>> method (which you overzealously snipped, no surprise) for
>> generating i is guaranteed to be portable.
>
> I don't think a portable decimal-to-floating-point conversion
> function that is no less accurate than the C Standard would
> require compilers to be when processing floating-point literals
> should be especially difficult.  [...]

That's because you've never tried to write one.  Remember, the
Standard makes almost no portable guarantees about the accuracy
of floating-point operations.  Cf. section 5.2.4.2.2.

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


#101898

From"Chris M. Thomasson" <invalid@invalid.invalid>
Date2017-01-15 15:41 -0800
Message-ID<o5h184$o9r$1@dont-email.me>
In reply to#101847
On 1/15/2017 8:45 AM, Fernando D. Bozzo wrote:
> From the beginning of my course I'm looking a way to define an array with a number of elements based on some other variable which I don't know, but without using the dynamic memory space (with malloc)
>
> May be I have a conceptual error here, but just in case I did prefer to ask.
>
> I want to do something like this:
>
> len = (some calculated length that can vary in every execution);
> char myArray[len];
>
>
> I've tryied this way, but didn't compile. My aim is not needing to free() it later, but that this array get cleared as all other auto variables.
>
>
> Thanks.-

FWIW, here is a little crude example of using a scoped stack based 
region allocation scheme for creating a dynamic memory like mimic for a 
diverse set of algorithms:

crude hacky (wrt alignment) code:

http://pastebin.com/raw/f37a23918
(pastebin link without ads, notice the raw?)

https://groups.google.com/forum/#!original/comp.lang.c++/7oaJFWKVCTw/sSWYU9BUS_QJ

Hope this can help out a bit. ;^o

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


#101899

From"Fernando D. Bozzo" <fdbozzo@gmail.com>
Date2017-01-15 15:44 -0800
Message-ID<d22a7415-0276-4097-8cd8-1c935a92272f@googlegroups.com>
In reply to#101898
El lunes, 16 de enero de 2017, 0:41:31 (UTC+1), Chris M. Thomasson  escribió:
> On 1/15/2017 8:45 AM, Fernando D. Bozzo wrote:
> > From the beginning of my course I'm looking a way to define an array with a number of elements based on some other variable which I don't know, but without using the dynamic memory space (with malloc)
> >
> > May be I have a conceptual error here, but just in case I did prefer to ask.
> >
> > I want to do something like this:
> >
> > len = (some calculated length that can vary in every execution);
> > char myArray[len];
> >
> >
> > I've tryied this way, but didn't compile. My aim is not needing to free() it later, but that this array get cleared as all other auto variables.
> >
> >
> > Thanks.-
> 
> FWIW, here is a little crude example of using a scoped stack based 
> region allocation scheme for creating a dynamic memory like mimic for a 
> diverse set of algorithms:
> 
> crude hacky (wrt alignment) code:
> 
> http://pastebin.com/raw/f37a23918
> (pastebin link without ads, notice the raw?)
> 
> https://groups.google.com/forum/#!original/comp.lang.c++/7oaJFWKVCTw/sSWYU9BUS_QJ
> 
> Hope this can help out a bit. ;^o


Hi Chris, I've make it work. VLAs work ok for me now. Don't know how I've tested it some days ago, but I surely did typed or defined something wrong.

Very thanks for your links!

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


#101903

From"Chris M. Thomasson" <invalid@invalid.invalid>
Date2017-01-15 16:17 -0800
Message-ID<o5h3bd$u6h$1@dont-email.me>
In reply to#101899
On 1/15/2017 3:44 PM, Fernando D. Bozzo wrote:
> El lunes, 16 de enero de 2017, 0:41:31 (UTC+1), Chris M. Thomasson  escribió:
>> On 1/15/2017 8:45 AM, Fernando D. Bozzo wrote:
>>> From the beginning of my course I'm looking a way to define an array with a number of elements based on some other variable which I don't know, but without using the dynamic memory space (with malloc)
>>>
>>> May be I have a conceptual error here, but just in case I did prefer to ask.
>>>
>>> I want to do something like this:
>>>
>>> len = (some calculated length that can vary in every execution);
>>> char myArray[len];
>>>
>>>
>>> I've tryied this way, but didn't compile. My aim is not needing to free() it later, but that this array get cleared as all other auto variables.
>>>
>>>
>>> Thanks.-
>>
>> FWIW, here is a little crude example of using a scoped stack based
>> region allocation scheme for creating a dynamic memory like mimic for a
>> diverse set of algorithms:
>>
>> crude hacky (wrt alignment) code:
>>
>> http://pastebin.com/raw/f37a23918
>> (pastebin link without ads, notice the raw?)
>>
>> https://groups.google.com/forum/#!original/comp.lang.c++/7oaJFWKVCTw/sSWYU9BUS_QJ
>>
>> Hope this can help out a bit. ;^o
>
>
> Hi Chris, I've make it work. VLAs work ok for me now.

Excellent news. :^)


> Don't know how I've tested it some days ago, but I surely did typed or defined something wrong.

Well, shi% happens.


> Very thanks for your links!

No problem. FWIW, the region allocator can derive space for different 
sized objects. It should be able to be converted into a more standard 
form wrt max_align_t, alignas, alignof, c11... ;^)

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


#101943

FromAlla _ <modelling.data@gmail.com>
Date2017-01-16 01:47 -0800
Message-ID<394e6d44-0ba1-4590-9859-41bda59e7000@googlegroups.com>
In reply to#101847
On Sunday, January 15, 2017 at 7:45:57 PM UTC+3, Fernando D. Bozzo wrote:
> From the beginning of my course I'm looking a way to define an array with a number of elements based on some other variable which I don't know, but without using the dynamic memory space (with malloc)
<snip>
Could you, please, share what course are you taking?

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


#101944

From"Fernando D. Bozzo" <fdbozzo@gmail.com>
Date2017-01-16 01:50 -0800
Message-ID<d480b657-20cf-47bb-a24b-30a1d1de3cd6@googlegroups.com>
In reply to#101943
Yeah, sure:  CS50, at edX ;-)

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


#101946

FromAlla _ <modelling.data@gmail.com>
Date2017-01-16 02:38 -0800
Message-ID<4902e769-722c-4aef-a9ed-09dcd4487fe4@googlegroups.com>
In reply to#101944
On Monday, January 16, 2017 at 12:50:39 PM UTC+3, Fernando D. Bozzo wrote:
> Yeah, sure:  CS50, at edX ;-)

Oh ) I sensed it could be the one ) How did you find this group? )
I am now doing my final project, and I have chosen to do it in C. 
Beware - some people here don't think it's a good course ) 

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


#101947

From"Fernando D. Bozzo" <fdbozzo@gmail.com>
Date2017-01-16 03:15 -0800
Message-ID<3ca43710-256e-4ea2-805a-2e388a1325a8@googlegroups.com>
In reply to#101946
El lunes, 16 de enero de 2017, 11:38:33 (UTC+1), Alla _  escribió:
> On Monday, January 16, 2017 at 12:50:39 PM UTC+3, Fernando D. Bozzo wrote:
> > Yeah, sure:  CS50, at edX ;-)
> 
> Oh ) I sensed it could be the one ) How did you find this group? )
> I am now doing my final project, and I have chosen to do it in C. 
> Beware - some people here don't think it's a good course )

Well, I use a lot of groups on Google Groups, so I just searched for
C-related ones and found just this one with activity, and found to on the web that this is a legendary one with great people, so I get in.

I don't care what others think about this course, and given what I'd read
about it before taking it, and the link you provided
(https://paw.princeton.edu/article/computer-languages-clarity-key) makes
clear that it's a course not focused on the higher skills devs, but on the
ones that are new to C and Computer Science.

A course on which the same Davin Malan, ex-student of legendary Kernighan,
is one of the Professors, can't be bad, and more given the special interest
that this people put in teaching in a way very close to the students.

I'm really enjoying it, and I'm in week 7 with the practice on the apache
server "fix", which I've almost done :)

Don't know yet about what will be my final project, but thinking on it :/

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


#101951

FromAlla _ <modelling.data@gmail.com>
Date2017-01-16 03:40 -0800
Message-ID<d12735b3-b8f3-4fc4-9fb8-6d1a6769e0cb@googlegroups.com>
In reply to#101947
On Monday, January 16, 2017 at 2:15:41 PM UTC+3, Fernando D. Bozzo wrote:
> El lunes, 16 de enero de 2017, 11:38:33 (UTC+1), Alla _  escribió:
> > On Monday, January 16, 2017 at 12:50:39 PM UTC+3, Fernando D. Bozzo wrote:
> > > Yeah, sure:  CS50, at edX ;-)
> > 
> > Oh ) I sensed it could be the one ) How did you find this group? )
> > I am now doing my final project, and I have chosen to do it in C. 
> > Beware - some people here don't think it's a good course )
> 
> Well, I use a lot of groups on Google Groups, so I just searched for
> C-related ones and found just this one with activity, and found to on the web that this is a legendary one with great people, so I get in.
> 
> I don't care what others think about this course, and given what I'd read
> about it before taking it, and the link you provided
> (https://paw.princeton.edu/article/computer-languages-clarity-key) makes
> clear that it's a course not focused on the higher skills devs, but on the
> ones that are new to C and Computer Science.
> 
> A course on which the same Davin Malan, ex-student of legendary Kernighan,
> is one of the Professors, can't be bad, and more given the special interest
> that this people put in teaching in a way very close to the students.
> 
> I'm really enjoying it, and I'm in week 7 with the practice on the apache
> server "fix", which I've almost done :)
> 
> Don't know yet about what will be my final project, but thinking on it :/

Yes, it is the best course ever, especially because of all those people working
on it - David, Rob, and others; truly outstanding staff, exceptional learning 
experience, and what's very important these guys do care about every single
student, and there are tens of thousands of us taking the course, if not hundreds
already. I was also amazed to read the article I have posted here. A lot can be
said on all this, but I do feel we are very lucky to have an opportunity to take 
the course. 
Also thanks to this course I have found this group - a gold mine of exceptional 
professionals. So, please, don't say you don't care - heed to every word people
tell you here; if they do say something, they know what they are saying; even if you hear 
something not pleasant (though I don't think you will), it's nothing compared to
being able to get advices from fellows here; it just all depends
on a personal character, but we are all different and that's good ))) 
I believe you have some prior experience in CS. I was minus 100%, knew nothing
at all. 
As to final projects, people tend to do something amazing - apps, games, etc. 
I have decided to opt out of this, and do something more practical in terms of 
getting a deeper knowledge of C because I love the language. 
As to apache, I have huge problems now with my local one. Can't figure out why
it doesn't work. But I better stop discussing these issues here, these are not
C related, and I will be fairly chastised for doing so. 
Happy you have found this group. Good luck with the course )

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


#101954

From"Fernando D. Bozzo" <fdbozzo@gmail.com>
Date2017-01-16 04:21 -0800
Message-ID<b7b15e09-aebb-4931-9372-b1ec3305976f@googlegroups.com>
In reply to#101951
El lunes, 16 de enero de 2017, 12:40:57 (UTC+1), Alla _  escribió:
> [...] So, please, don't say you don't care - heed to every word people
> tell you here [...] 

I think you did misinterpret what I said:
> I don't care what others think about this course [...]

It only applies to this in particular, not to everything else!

I really appreciate all the guidance found here, and take seriously all
the suggestions and comments.

--

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


#101956

FromAlla _ <modelling.data@gmail.com>
Date2017-01-16 04:29 -0800
Message-ID<8283c602-7e77-4d6f-9e83-db01fb35f38d@googlegroups.com>
In reply to#101947
On Monday, January 16, 2017 at 2:15:41 PM UTC+3, Fernando D. Bozzo wrote:
> El lunes, 16 de enero de 2017, 11:38:33 (UTC+1), Alla _  escribió:
> > On Monday, January 16, 2017 at 12:50:39 PM UTC+3, Fernando D. Bozzo wrote:
> > > Yeah, sure:  CS50, at edX ;-)
> > 
> > Oh ) I sensed it could be the one ) How did you find this group? )
> > I am now doing my final project, and I have chosen to do it in C. 
> > Beware - some people here don't think it's a good course )
> 
> Well, I use a lot of groups on Google Groups, so I just searched for
> C-related ones and found just this one with activity, and found to on the web that this is a legendary one with great people, so I get in.
> 
> I don't care what others think about this course, and given what I'd read
> about it before taking it, and the link you provided
> (https://paw.princeton.edu/article/computer-languages-clarity-key) makes
> clear that it's a course not focused on the higher skills devs, but on the
> ones that are new to C and Computer Science.
> 
> A course on which the same Davin Malan, ex-student of legendary Kernighan,
> is one of the Professors, can't be bad, and more given the special interest
> that this people put in teaching in a way very close to the students.
> 
> I'm really enjoying it, and I'm in week 7 with the practice on the apache
> server "fix", which I've almost done :)
> 
> Don't know yet about what will be my final project, but thinking on it :/
Just out of curiosity - you can skip this if you don't want to reply. Why are 
you now learning about C if you are at pset7? By this time you are done with
C based on course's material.

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


#101957

From"Fernando D. Bozzo" <fdbozzo@gmail.com>
Date2017-01-16 04:36 -0800
Message-ID<86afdc03-495f-42aa-b902-4930406d617c@googlegroups.com>
In reply to#101956
Because it's not enough with the course
materials, and I like to read info on
more sites, know the history behind and
ask the questions I can't found clear
enough. 
Odds are asking on Stackoverflow and here.

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


Page 7 of 8 — ← Prev page 1 2 3 4 5 6 [7] 8  Next page →

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


csiph-web