Re: [docs and wiki] How many data-types do we emphasize?
- Posted by irv Jan 30, 2021
- 1152 views
katsmeow said...
I'd like to stress the user type, the way OE implements it now.
1) it's faithfully called on every assignment
2) it's programmable!!!
3) there seems to be no limit to how many unique types there are in a program or include
Kat
Thanks Kat:
As you point out, it also goes beyond just enforcing a type. I find this sort of thing helpful:
------------------------------- global type db_err(object x) -- trap eds errors in db procedures; ------------------------------- if x != DB_OK then -- show popup message as well as in the terminal (if used): display("Database Error: [] [] []",{x,decode_err(x),get("input_entry.text")}) Error("MainWin",format("Database error code []",x), format("DB: []",{get("input_entry.text")}), -- db name user entered; format("[]",{decode_err(x)}),GTK_BUTTONS_OK) -- from db error table; return 1 end if return x = DB_OK end type db_err x = db_open("bad.edb") -- open, or issue warning, no crash.
Nearly identical routines can create tbl_err and rec_err types, to handle calls such as db_create_table, db_select_table, db_insert, etc.