Thread overview |
---|
August 28, 2001 Idea I had while coding, not sure if it's unrealistic in a strongly type language... | ||||
---|---|---|---|---|
| ||||
If so, please tell me how unrealistic, just throwing out the idea. Built-in array concatination. byte[] b = new byte[3]; byte[] c = new byte[5]; byte[] d = b + c; ( d is now a new byte[], an empty byte[8] ) int[] e = new int[10]; d = c + e; // error - can't mix byte[] and int[] The idea is simple. It just came up while working and I hit a particularly nasty pocket of objects. Of course, libraries could provide this sevice (not this nicely without operator overloading...) and I've written my own libraries in both C++ and Java to accomplish it. But instead of calling functions, why not treat arrays like Strings as far as simple '+' concatination goes? I will admit that I didn't check the language spec before posting this because I'm working and I can't take much time out. I don't REMEMBER it being there... if it is already, I applaud Walter once again and return to work gracefully. If not, then any thoughts? -Brady |
August 29, 2001 Re: Idea I had while coding, not sure if it's unrealistic in a strongly type language... | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bradeeoh | Bradeeoh wrote:
>
> If so, please tell me how unrealistic, just throwing out the idea.
>
> Built-in array concatination.
>
> byte[] b = new byte[3];
> byte[] c = new byte[5];
> byte[] d = b + c;
> ( d is now a new byte[], an empty byte[8] )
>
> int[] e = new int[10];
> d = c + e; // error - can't mix byte[] and int[]
>
> The idea is simple. It just came up while working and I hit a particularly nasty pocket of objects.
>
> Of course, libraries could provide this sevice (not this nicely without operator overloading...) and I've written my own libraries in both C++ and Java to accomplish it. But instead of calling functions, why not treat arrays like Strings as far as simple '+' concatination goes?
>
> I will admit that I didn't check the language spec before posting this because I'm working and I can't take much time out. I don't REMEMBER it being there... if it is already, I applaud Walter once again and return to work gracefully.
>
> If not, then any thoughts?
>
> -Brady
Actually, when I read the spec the first time I got the idea that:
array0 = array1 + array2
for array's of the same size (that was required) meant:
for(int i=0; i < array.length; i++)
array0[i] = array1[i] + array2[i];
and I figured it was good that at least array addition would look like addition. When trying to verify my belief I reread the spec and mournfully convinced myself that it was array concatenation. I guess I'd like to know which is it.
Dan
|
September 01, 2001 Re: Idea I had while coding, not sure if it's unrealistic in a strongly type language... | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dan Hursh | Dan Hursh a écrit :
>
> Bradeeoh wrote:
> >
> > If so, please tell me how unrealistic, just throwing out the idea.
> >
> > Built-in array concatination.
> >
> > byte[] b = new byte[3];
> > byte[] c = new byte[5];
> > byte[] d = b + c;
> > ( d is now a new byte[], an empty byte[8] )
> >
> > int[] e = new int[10];
> > d = c + e; // error - can't mix byte[] and int[]
> >
> > The idea is simple. It just came up while working and I hit a particularly nasty pocket of objects.
> >
> > Of course, libraries could provide this sevice (not this nicely without operator overloading...) and I've written my own libraries in both C++ and Java to accomplish it. But instead of calling functions, why not treat arrays like Strings as far as simple '+' concatination goes?
> >
> > I will admit that I didn't check the language spec before posting this because I'm working and I can't take much time out. I don't REMEMBER it being there... if it is already, I applaud Walter once again and return to work gracefully.
> >
> > If not, then any thoughts?
> >
> > -Brady
>
> Actually, when I read the spec the first time I got the idea that:
>
> array0 = array1 + array2
>
> for array's of the same size (that was required) meant:
>
> for(int i=0; i < array.length; i++)
> array0[i] = array1[i] + array2[i];
>
> and I figured it was good that at least array addition would look like addition. When trying to verify my belief I reread the spec and mournfully convinced myself that it was array concatenation. I guess I'd like to know which is it.
>
> Dan
Maybe we could introduice new operator as '.' (dot) or 'concat'. So introduice some other built-in operator. C introduice too few operator, we should add '**' or '^' for power.
nicO
nicO
|
September 01, 2001 Re: Idea I had while coding, not sure if it's unrealistic in a strongly type language... | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bradeeoh | It's already there in the language <g>. -Walter Bradeeoh wrote in message <9mfme5$v1g$1@digitaldaemon.com>... >If so, please tell me how unrealistic, just throwing out the idea. > >Built-in array concatination. > >byte[] b = new byte[3]; >byte[] c = new byte[5]; >byte[] d = b + c; >( d is now a new byte[], an empty byte[8] ) > >int[] e = new int[10]; >d = c + e; // error - can't mix byte[] and int[] > >The idea is simple. It just came up while working and I hit a particularly nasty pocket of objects. > >Of course, libraries could provide this sevice (not this nicely without operator overloading...) and I've written my own libraries in both C++ and Java to accomplish it. But instead of calling functions, why not treat arrays like Strings as far as simple '+' concatination goes? > >I will admit that I didn't check the language spec before posting this because I'm working and I can't take much time out. I don't REMEMBER it being there... if it is already, I applaud Walter once again and return to work gracefully. > >If not, then any thoughts? > >-Brady > > |
September 02, 2001 Re: Idea I had while coding, not sure if it's unrealistic in a strongly type language... | ||||
---|---|---|---|---|
| ||||
Posted in reply to nicO | >
> > Actually, when I read the spec the first time I got the idea that:
> >
> > array0 = array1 + array2
> >
> > for array's of the same size (that was required) meant:
> >
> > for(int i=0; i < array.length; i++)
> > array0[i] = array1[i] + array2[i];
> >
> > and I figured it was good that at least array addition would look like addition. When trying to verify my belief I reread the spec and mournfully convinced myself that it was array concatenation. I guess I'd like to know which is it.
> >
> > Dan
>
> Maybe we could introduice new operator as '.' (dot) or 'concat'. So introduice some other built-in operator. C introduice too few operator, we should add '**' or '^' for power.
^ is already used in C.
|
September 02, 2001 Re: Idea I had while coding, not sure if it's unrealistic in a strongly type language... | ||||
---|---|---|---|---|
| ||||
Posted in reply to kaffiene | kaffiene wrote:
>
> >
> > > Actually, when I read the spec the first time I got the idea that:
> > >
> > > array0 = array1 + array2
> > >
> > > for array's of the same size (that was required) meant:
> > >
> > > for(int i=0; i < array.length; i++)
> > > array0[i] = array1[i] + array2[i];
> > >
> > > and I figured it was good that at least array addition would look like addition. When trying to verify my belief I reread the spec and mournfully convinced myself that it was array concatenation. I guess I'd like to know which is it.
> > >
> > > Dan
> >
> > Maybe we could introduice new operator as '.' (dot) or 'concat'. So introduice some other built-in operator. C introduice too few operator, we should add '**' or '^' for power.
>
> ^ is already used in C.
For that matter, ** won't work because the is already an infix and binary * operator.
x ** y => x * (*y)
I agree with the idea though. I like perl because of it's liberal use of infix and unary operations. I like C++ because it let me do the same, but it would be nice to have more operator symbol at my disposal, and to be and to mess with precedence. Since before first grade we are taught infix operations. They feel much more natural for anything remotely numeric.
Dan
|
September 02, 2001 Re: Idea I had while coding, not sure if it's unrealistic in a strongly type language... | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dan Hursh | > For that matter, ** won't work because the is already an infix and binary * operator.
>
> x ** y => x * (*y)
C is already broken in this regard:
x /* y => x / (*y)
Right? No, it's a comment :o)
- Axel
|
Copyright © 1999-2021 by the D Language Foundation