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


Groups > comp.lang.c > #19235

Re: What's wrong with this simple code?

From nick_keighley_nospam@hotmail.com
Newsgroups comp.lang.c
Subject Re: What's wrong with this simple code?
Date 2012-03-29 00:16 -0700
Organization http://groups.google.com
Message-ID <32414541.2329.1333005375183.JavaMail.geo-discussion-forums@vbhv6> (permalink)
References <48d7ec09-3c0d-4e4a-9c95-3479417fbf34@x5g2000pbl.googlegroups.com> <4F70ACDA.9040902@verizon.net> <7325db7d-ab77-4838-b7f4-0c884bc52e04@oq7g2000pbb.googlegroups.com>

Show all headers | View raw


On Thursday, March 29, 2012 1:23:12 AM UTC+1, fajar96te wrote:

> This left me wonder... is there any design-reason behind this peculiar
> grammar of C? 

it's not a grammer thing its a sematics (meaning) thing. I must have been programming in C for too long; it doesn't look in the slightest bit peculiar to me!

> i.e., that one cannot assign to an array? Will it hurt
> if one can directly assign an array as easily as k = "abc"; as one
> would an integer?

It's probably as simple as Dennis Richie didn't see a need for it. 

C statements usually expand to very little machine code. Array 
assignment would expand to quite a lot. Though this arguemtn is 
undermined by the observation that struct assignment, which is 
allowed, also expands to quite a lot of code.

I suspect the semantics of array argument passing would become a 
bit messy. You don't really pass an array argument to a function, 
ot "decays" into a pointer. I suspect array assignment would have
quite a ripple affect through other parts of the language.


Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

What's wrong with this simple code? fajar96te <fajar.suryawan@gmail.com> - 2012-03-26 09:28 -0700
  Re: What's wrong with this simple code? blp@cs.stanford.edu (Ben Pfaff) - 2012-03-26 09:45 -0700
  Re: What's wrong with this simple code? Jens Gustedt <jens.gustedt@loria.fr> - 2012-03-26 18:45 +0200
  Re: What's wrong with this simple code? "BartC" <bc@freeuk.com> - 2012-03-26 17:45 +0100
  Re: What's wrong with this simple code? jt@toerring.de (Jens Thoms Toerring) - 2012-03-26 16:50 +0000
  Re: What's wrong with this simple code? James Kuyper <jameskuyper@verizon.net> - 2012-03-26 13:52 -0400
    Re: What's wrong with this simple code? nick_keighley_nospam@hotmail.com - 2012-03-29 00:16 -0700
    Re: What's wrong with this simple code? fajar96te <fajar.suryawan@gmail.com> - 2012-03-28 17:23 -0700
      Re: What's wrong with this simple code? Sjouke Burry <s@b> - 2012-04-02 20:39 +0000
      Re: What's wrong with this simple code? "BartC" <bc@freeuk.com> - 2012-04-02 22:07 +0100

csiph-web