Re: What's the point of map:map type if load_map() messes it up?

new topic     » goto parent     » topic index » view thread      » older message » newer message
jeremy said...
DerekParnell said...
jeremy said...

I wonder if in cases like this the map type shouldn't support an error condition.

I wonder if we should wait until we get a comprehensive solution, such as exceptions built into the language.

I wonder when that will happen? I don't think it's on the books for 4.1? Thus maybe 4.2?

Jeremy

I thought exceptions were being added in 5.0

Unless we have plans for implementation exceptions immediately, we need some kind of compromise.

I came up with a very generic, if somewhat unwieldy, way to deal with this:

-- generic type test 
public function gtt(object value, integer routine_id_of_type, integer routine_id_of_error_handling_procedure, object default_valid_value) 
	if not call_func(routine_id_of_type, {value}) then 
		if routine_id_of_error_handing_procedure >= 0 then 
			call_proc(routine_id_of_error_handling_procedure, {value}) 
			--return call_func(routine_id_of_error_handling_function, {value}) 
		end if 
		return default_valid_value 
	end if 
end function 
 
--public constant NO_ROUTINE_ID = -2 
map:map t = ggt(map:load_map("file"), routine_id("map:map"), NO_ROUTINE_ID, empty_map) 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu