Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Compilers LCC > Re: why cant fu...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 1036 of 1070
Post > Topic >>

Re: why cant functions return arrays

by jacob navia <jacob@[EMAIL PROTECTED] > Apr 21, 2008 at 05:21 PM

Ben Bacarisse wrote:
> jacob navia <jacob@[EMAIL PROTECTED]
> writes:
> 
>> Keith Thompson wrote:
>> [snip]
>>
>>> What could be done, I suppose, is to add an entirely new array-like
>>> construct to C, one that doesn't depend on pointer semantics for its
>>> fundamental operations or decay to a pointer in most contexts.  Let's
>>> call it a "vector".  
>> Correct. This is the way that lcc-win has choosen. Using
>> operator overloading of the '[' and ']' operators lcc-win
>> offers a true array type that doesn't "decay" to anything.
> 
> Way off-topic now so I've set followup-to comp.compilers.lcc, but I
> can't see how that can do anything.  In this code:
> 
>   int a[10];
>   f(a);
> 
> there are no [] operators, so how does the compiler know which sort of
> array I want?
> 

Because you tell it to:

int a[10]; // Normal C array
Vector v = newVector(10,sizeof(int));

a[2] = 5;
v[2] = 5;

> <snip>
>> ... Operator overloading provides a simple and elegant solution as
>> I have been claiming since several years now.
> 
> I think treating initialisation as assignment and, if I recall
> correctly, *not* treating argument passing as assignment makes your
> operator overloading much less useful than it might have been.
> 

All argument passing are assignments in standard C.

But if you want C++, no, it is not C++.

-- 
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
 




 1 Posts in Topic:
Re: why cant functions return arrays
jacob navia <jacob@[EM  2008-04-21 17:21:05 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Oct 10 23:44:49 CDT 2008.