[wp-svg-icons icon=”podcast” wrap=”div”]

Never encode a constant in more than one place.
So I had to resist the temptation to write code like1

[eiffel]
tag_types: INDEXABLE[STRING]
once
Result := {FAST_ARRAY[STRING], < <
“Void”, — GI_TYPE_TAG_VOID = 0,
“BOOLEAN”, — GI_TYPE_TAG_BOOLEAN = 1,

“INTEGER_64”, — GI_TYPE_TAG_INT64 = 8 …. >>

[/eiffel]
No way, dudes. What’s if the authors of GObject introspection will change those numbers? We will be screwed.
So the correct implementation is:
[eiffel]
create {FAST_ARRAY[STRING]} Result.with_capacity(32)
Result.put(“FAST_ARRAY”,array_low_level)
Result.put(“BOOLEAN”,boolean_low_level)
Result.put(“REAL”,double_low_level)
Result.put(“”,error_low_level)
Result.put(“STRING”,filename_low_level)
Result.put(“REAL_32”,float_low_level)
Result.put(“G_HASH_TABLE”,ghash_low_level)
Result.put(“G_LIST”,glist_low_level)
Result.put(“G_SLIST”,gslist_low_level)
Result.put(“”,gtype_low_level)
Result.put(“INTEGER_16”,int16_low_level)
Result.put(“INTEGER”,int32_low_level)
[/eiffel]


  1. oh, I shall add Eiffel syntax highlight here 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.