www.digitalmars.com         C & C++   DMDScript  

D - delete on arrays and associative arrays

reply "Charles Sanders" <sanders-consulting comcast.net> writes:
Using delete on an associative array will remove the element and resize the
array .

Using delete on a dynamic ( or otherwise ) array will just leave a blank
spot in the middle of the array, not resizing.

Could we have a 'remove' property that will remove the element , and resize
the array ?

I think this would go along way to help make the language more consistent
and useful.


C
Dec 10 2003
parent reply Ilya Minkov <Ilya_member pathlink.com> writes:
I suggest array and other language primitives which can be expressed as structs
get their place as structs in the standard library. Some syntax would translate
to certain methods, but also all other methods and propeties should be acessible
directly. A compiler switch or inifile setting should specify in which namespace
to look for definitions.

This would allow the Standard Library group to enhance basic types.

-eye

In article <br7v4r$1lki$1 digitaldaemon.com>, Charles Sanders says...
Using delete on an associative array will remove the element and resize the
array .

Using delete on a dynamic ( or otherwise ) array will just leave a blank
spot in the middle of the array, not resizing.

Could we have a 'remove' property that will remove the element , and resize
the array ?

I think this would go along way to help make the language more consistent
and useful.


C
Dec 10 2003
parent J Anderson <REMOVEanderson badmama.com.au> writes:
Ilya Minkov wrote:

I suggest array and other language primitives which can be expressed as structs
get their place as structs in the standard library. Some syntax would translate
to certain methods, but also all other methods and propeties should be acessible
directly. A compiler switch or inifile setting should specify in which namespace
to look for definitions.

This would allow the Standard Library group to enhance basic types.

-eye

In article <br7v4r$1lki$1 digitaldaemon.com>, Charles Sanders says...
  

Using delete on an associative array will remove the element and resize the
array .

Using delete on a dynamic ( or otherwise ) array will just leave a blank
spot in the middle of the array, not resizing.

Could we have a 'remove' property that will remove the element , and resize
the array ?

I think this would go along way to help make the language more consistent
and useful.


C


    
Parhaps something like: extend int { void remove(...) ... } Allowing anyone to add methods to the standard primitive (it could be used for classes as well but then it might take the place of inheritance). PS - I suggested this before for operator overloading, for the _r side, before it was implemented.
Dec 11 2003