Talk:Assigning Values to an Array: Difference between revisions

From Rosetta Code
Content added Content deleted
(Just fixed some very minor typo's)
No edit summary
Line 1: Line 1:


Why disturb something as simple as assigning a value in an array with a method/function
Why disturb something as simple as assigning a value in an array with a method/function
declaration?
declaration?

: Seconded: am I supposed to assign a value to an array or write a function/routine/procedure to assign a value to an array? [[User:Sgeier|Sgeier]] 01:09, 20 February 2007 (EST)



== Type of error to return? Type of index? ==
== Type of error to return? Type of index? ==

Revision as of 06:09, 20 February 2007


Why disturb something as simple as assigning a value in an array with a method/function declaration?

Seconded: am I supposed to assign a value to an array or write a function/routine/procedure to assign a value to an array? Sgeier 01:09, 20 February 2007 (EST)


Type of error to return? Type of index?

This task leaves a lot up in the air. Some languages can only do numerical indexes, some can do anything. Also, the requirements say to return an error if the key doesn't exist. None of the languages at this time fulfill this requirement, except Ada, which will throw an exception if the key is out of bounds.

I flagged the task for clarification. --Short Circuit 22:42, 22 January 2007 (EST)
I think it is that most of the languages (e.g. Python, Java) automatically raise exceptions when an index is out of range. And most languages have in place a way to capture those exceptions and deal with it. Therefore, you do not need to explicitly raise an error unless you deem it necessary. Maybe change the specification to raise an error where applicable for languages that do not have mechanisms in place to handle such exceptions? Such as C for example? --Adonis 17:59, 24 January 2007 (EST)