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 2 Topic 1038 of 1066
Post > Topic >>

Re: why cant functions return arrays

by Ben Bacarisse <ben.usenet@[EMAIL PROTECTED] > Apr 21, 2008 at 11:15 PM

jacob navia <jacob@[EMAIL PROTECTED]
> writes:

> Ben Bacarisse wrote:
>> I added #include <vector.h> and wrapped it in a main function, but
>> this does not compile.  Are vectors a work in progress?
>>
<snip vector example>

Right.  I read the tutorial.  What puzzled me is why you would post
incorrect syntax when explaining something about your own system.

>> At any rate, as far as I can see you agree with me.  You don't do it
>> as you seemed to be suggesting with an array that does not decay to a
>> pointer.  You just use a new type -- most likely some sort of struct
>> type.
>
> Operator overloading works with new types. This avoid all the problems
> of mixing two data structures that are completely different with the
> same notation.

Then I think you should have replied to Keith by saying that you do
it a different way.  He was suggesting something else.

>>>> <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.
>>
>> Yes I know.  I was curious as to why they seem to be excluded, since
>> they are, in effect assignments.  In other words, having defined
>> assignment for type T from type X, I'd expect to see it used when
>> passing an X to function taking a T.
>>
>
> They are not excluded. I may have bugs in my implementation.

It is not im****tant to me.  I was just curious about why it did not
work.

>> However, I now discover that for some reason one can't define
>> assignment between two type T objects. 
>
> You mean
> T a,b;
>
> 	a=b;
>
> ??

Yes.

> The problem is that this is ALREADY defined in the standard
> language, and I tried to stay within C.

But you are extending C.  How odd to have decided this useful facility
is not permitted.

>> That seems to exclude lots of
>> useful implementations like reference counting and copy on write.  Are
>> the precise semantics of operator overloading and with is and is not
>> permitted written down anywhere?
>>
>
> Yes, in a do***ent that I have posted several times in comp.std.c.
> Nobody answered.

I can't image you mean the same do***ent that I read.  That is in no
way a specification.  It would be impossible to design a program based
on that information and equally impossible to tell if there is a bug
in the implementation.  Maybe I missed the do***ent you mean.

-- 
Ben.
 




 2 Posts in Topic:
Re: why cant functions return arrays
Ben Bacarisse <ben.use  2008-04-21 23:15:39 
Re: why cant functions return arrays
jacob navia <jacob@[EM  2008-04-22 00:31:53 

Post A Reply:
  Go here to Signup

AddThis Feed Button


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

Contact
tan12V112 Sun Sep 7 7:13:17 CDT 2008.