Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > some well known stupidness in c99

Reply
Thread Tools

some well known stupidness in c99

 
 
fir
Guest
Posts: n/a
 
      11-20-2012
>
>
> the question is how syntax to choose to distinguish between pointers-to-one and pointers-to-many in such cases:
>
> void print(char* text) //pointer to undefined many
> {
>
> }
>
> void print(char(1)* text) //pointer to one ?
> {
>
> }


also think sometimes (like here) if java-like
syntax wouldnt be clearer

char a; //a is adress to one
char[] a; //a is adress to undefined many
char[16] a; //a is adress to chunk of 16 chars

it seem clearer and *a could be reserved
eventually for old way
 
Reply With Quote
 
 
 
 
fir
Guest
Posts: n/a
 
      11-20-2012
>
> I guess that English is not your first language, so perhaps you're
> not aware that the word "stupid" is quite insulting. I suggest
>


I do like c in very much extent so it sound
totaly fantastic (not real( to me, I use
called it stupidness becouse I was/am real
angry/mad to know that I cannot use const int
in c99 and finding also explanation sort of 'consyt int x doeas not mean that x is const'
(and the fact that i can throw c compilers to trashbin)
I feel i can call it stupidnees though some
explanations what do I mean would be required
- I said what do I meant


 
Reply With Quote
 
 
 
 
fir
Guest
Posts: n/a
 
      11-20-2012
so (maybe I add it) i called it stupidness
in some way especially for its 'unpleasaant'
annoying consequences, though not giving better alternative to defines and enums also
is not to much wise for me but do not matter
(i do not want to hold on this word here to
much, maybe I shouldnt use it and use something
like 'bad thing' or 'annoying thing'

there should be also argumentation why define
is considered bad for me but i never reflected
on it too much, all preprocesor seem to me
like to much primitive rules tool and it is not so much bad as an external tool over c
but is bad for me if considered as an inavoidable part of c - (and enum way is silly ) - so it is like here it is :/


 
Reply With Quote
 
fir
Guest
Posts: n/a
 
      11-20-2012
>
> void print(char text[])
>
> {
> for(int i=0; i<lengthof(text); i++)
> put_char_on_console(text[i]);
> }
>


(soory for may maneer of writing under my own
posts, but I often feel a need to add more, and
there is no edit option so I use it this way)

eventually sizeof could be even considered
if

int a[100];

sizeof(a) // gives 400 bytes of size
sizeof(a[0]) // gives 4 bytes of size

sizeof(a[]) //could return 100 elements of size

(i am not saying that it is the better option
but it can be considered)

Those all ways considered are my own interest
couse I am working on some logical improvements to c language (codenamed also sometimes c2 language)
 
Reply With Quote
 
BartC
Guest
Posts: n/a
 
      11-20-2012


"fir" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

>> the question is how syntax to choose to distinguish between
>> pointers-to-one and pointers-to-many in such cases:
>> void print(char* text) //pointer to undefined many
>> {
>> }
>> void print(char(1)* text) //pointer to one ?
>> {
>> }


> also think sometimes (like here) if java-like
> syntax wouldnt be clearer
>
> char a; //a is adress to one
> char[] a; //a is adress to undefined many
> char[16] a; //a is adress to chunk of 16 chars
>
> it seem clearer and *a could be reserved
> eventually for old way


In my opinion, C type syntax is broken. And that's not just the convoluted
syntax.

It's because char[] means different things in different contexts: an array
in some places, and a pointer in another:

char a[]={65,66,67}; // array

void fn (char[] a); // pointer

char[] meaning array would be illegal in a parameter context, but instead of
leaving that hole in the 'map' of possible types, everything moves up one
instead! The penchant for C to gloss over any dereferences needed - or not
needed - to index an array/pointer, just confuses things further.

I think you have your work cut out...

--
Bartc

 
Reply With Quote
 
fir
Guest
Posts: n/a
 
      11-20-2012
W dniu wtorek, 20 listopada 2012 11:54:10 UTC+1 użytkownik Bart napisał:
> "fir" <(E-Mail Removed)> wrote in message
>
>
> >> the question is how syntax to choose to distinguish between
> >> pointers-to-one and pointers-to-many in such cases:
> >> void print(char* text) //pointer to undefined many
> >> {
> >> }
> >> void print(char(1)* text) //pointer to one ?
> >> {
> >> }

>
>
>
> > also think sometimes (like here) if java-like
> > syntax wouldnt be clearer
> >
> > char a; //a is adress to one
> > char[] a; //a is adress to undefined many
> > char[16] a; //a is adress to chunk of 16 chars
> >
> > it seem clearer and *a could be reserved
> > eventually for old way

>
>
>
> In my opinion, C type syntax is broken. And that's not just the convoluted
> syntax.
>
> It's because char[] means different things in different contexts: an array
> in some places, and a pointer in another:
>
>
>
> char a[]={65,66,67}; // array
>
> void fn (char[] a); // pointer
>
>
>
> char[] meaning array would be illegal in a parameter context, but insteadof
> leaving that hole in the 'map' of possible types, everything moves up one
> instead! The penchant for C to gloss over any dereferences needed - or not
> needed - to index an array/pointer, just confuses things further.
>
>
> I think you have your work cut out...
>


I do not understand 'cut out' phrase, but
I am thinking over applying logical
improvements for about and almost 10 years
till now and some good and logical ideas
(ways of improvements) arose

here this proposal seem also logical and
good one finally here (though some think
up over it is always good thing):

this could be considered as adding some
support for arrays in c, it would be this
way (as I repeat):

some length of operator should work
on arrays - in many cases it should work
in static (compiler) time, on some cases
then should use dynamic length info provided
in function call

arrays passing should offer some new way
of it

void foo(int some)
{
ShowBox( lengthof (some) );

//should give one - this is from compilet time static type analisis (givesone for all no arrays)
}

void foo(int[16] some)
{
ShowBox( lengthof (some) );

// should give 16 - compiler time info
}

void foo(int[] table)
{
ShowBox( lengthof (some) );

// this should give result based on number passed on stack (which then goes probably from static compiler info knowledge)
}


old pointer ways,

void foo(int* some)

void foo(int (*some)[16])

should probably be working to in old way,
thought probably pointer-to-one pointer-to-many type guarding should be used here too
(to skip off by casting if need probably)

this is logical and would work, some
syntaxic question as to use "int[] a" or
"int a[]" or lengthof(a) or lenghtof(a[]) or sizeof(a[]) would be for otherdetailed consideration maybe, but this would support
arrays reasonably nicely





 
Reply With Quote
 
fir
Guest
Posts: n/a
 
      11-20-2012
W dniu wtorek, 20 listopada 2012 11:54:10 UTC+1 użytkownik Bart napisał:
> "fir" <(E-Mail Removed)> wrote in message
>
> >
> > char a; //a is adress to one
> > char[] a; //a is adress to undefined many
> > char[16] a; //a is adress to chunk of 16 chars

>
>
> It's because char[] means different things in different contexts: an array
> in some places, and a pointer in another:
>
> char a[]={65,66,67}; // array
>
> void fn (char[] a); // pointer
>


this maybe is not so much bad that

int a[10]; //definietion

a[10]; //11th element

so this

int[10] a; //definietion
a[10]; //11th element

seem to be more logical, and also "int[10]" as
a type name seem to nicer

 
Reply With Quote
 
fir
Guest
Posts: n/a
 
      11-20-2012
W dniu wtorek, 20 listopada 2012 13:38:50 UTC+1 użytkownik pete napisał:
> fir wrote:
>
> >

>
> > so (maybe I add it) i called it stupidness

>
> > in some way especially for its 'unpleasaant'

>
> > annoying consequences,

>
> > though not giving better alternative to defines and enums also

>
> > is not to much wise for me but do not matter

>
> > (i do not want to hold on this word here to

>
> > much, maybe I shouldnt use it and use something

>
> > like 'bad thing' or 'annoying thing'

>
> >

>
> > there should be also argumentation why define

>
> > is considered bad for me but i never reflected

>
> > on it too much, all preprocesor seem to me

>
> > like to much primitive rules tool

>
> > and it is not so much bad as an external tool over c

>
> > but is bad for me if considered as an inavoidable part of c

>
> > - (and enum way is silly ) - so it is like here it is :/

>
>
>
> It is common for people to think
>
> that something else is stupid,
>
> because they can't understand it.
>


I meet often such ppl that call me stupid
(a horde of them) so I know it well - but here still this lack of other better than preprocesor and enum way seem not much wise
to me
 
Reply With Quote
 
Ben Bacarisse
Guest
Posts: n/a
 
      11-20-2012
fir <(E-Mail Removed)> writes:
<snip>
> int a[10]; //definietion
>
> a[10]; //11th element
>
> so this
>
> int[10] a; //definietion
> a[10]; //11th element
>
> seem to be more logical, and also "int[10]" as
> a type name seem to nicer


Nicer than what? As it happens, 'int[10]' is the type name
corresponding to the C declaration of 'a' that you wrote.

--
Ben.
 
Reply With Quote
 
fir
Guest
Posts: n/a
 
      11-20-2012
W dniu wtorek, 20 listopada 2012 13:52:40 UTC+1 użytkownik Ben Bacarisse napisał:
> fir <(E-Mail Removed)> writes:
>
> <snip>
>
> > int a[10]; //definietion

>
> >

>
> > a[10]; //11th element

>
> >

>
> > so this

>
> >

>
> > int[10] a; //definietion

>
> > a[10]; //11th element

>
> >

>
> > seem to be more logical, and also "int[10]" as

>
> > a type name seem to nicer

>
>
>
> Nicer than what? As it happens, 'int[10]' is the type name
>
> corresponding to the C declaration of 'a' that you wrote.
>

sorry for my weak english (most of my english
comest from RATM lyrics, and many rereadings of Nabokov's Pnin in english)

I mean that this way of array definition seem
to be better (than present)

int t[100]; <- worse

int[100] t; <- better

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Is this phase-accumulator trick well-known??? Mike Treseler VHDL 0 02-08-2009 07:17 PM
List mutation method gotcha - How well known? Hendrik van Rooyen Python 20 03-16-2008 09:55 AM
Difference between "library parts" of C99 and "language parts" of C99 albert.neu@gmail.com C Programming 3 03-31-2007 08:14 PM
C99 struct initialization (C99/gcc) jilerner@yahoo.com C Programming 3 02-20-2006 04:41 AM
well-known Internet sites which use Java based web servers Mladen Adamovic Java 3 10-24-2005 09:48 PM



Advertisments