namespace Display { typedef = private; (Display*) connect(); (Display*) init_with_hooks(const Hooks* hooks); () close(Display*? this); (Status) set_ui_definition(Display* this, const UIDefinition *keep ui_def); /* TODO Each task will need some state, and the format of the state depends on the task type. I'm not sure if this is possible with the current type system (maybe with constraints). In most OO languages we could just use a virtual function (which is type safe, because only the constructor can assign it's address). Maybe it can be done with union types and constraints? The problem is that we must force the this pointer to be of a given type, even in places where the base type is used. typedef A = ( // Restricted this pointer ()(A* this constraint(value^.f == f))* f, ); typedef B = ( // How to create a union of these? union ( A original_type, // FIXME need sth like constraint(original_type is a type of B), ( // Is this type compatible (for all valid values)? ()(B* this constraint(value^.f == f))* f, ) overridden_type, ) base, byte[10] specific_data, ); */ () add_task(Display* this, Task* task); () remove_task(Display* this, Task* task); () queue_repaint(Display* this, Task* task); namespace Hooks { typedef = ( // TODO ); } } /* Overall structure: Static: Target: Dynamic: Task: For example a document or a web page. Might be presented as a tab in a window. Examples: Web browser: target: commands/parameters (back, address bar, title), document (web page) status: download progress task: web page Terminal: target: commands/parameters (copy&paste, reset, ) console status: more output, command finished task: shell E-mail client: target: commands/parameters (settings) subtasks: folder target (folder): commands/parameters (new e-mail) list of e-mails subtask: e-mail status: new e-mails target (e-mail): commands/parameters (reply [if incoming], send [if new]) text attachments tasks: folder e-mail IRC chat client: target: commands/parameters (settings) subtasks: channels target (channel): commands/parameters (kick, op, key exchange) conversation text user list status: new messages, highlight messages tasks: channel GIMP Plugin: target: command/parameters (ok, cancel, each parameter) tasks: image Dialog box: target: command/parameters (yes, no, etc...) text status: user input needed tasks: Depends. Could be a web page if the dialog box is created by a browser plugin. */ namespace UIDefinition { typedef = ( count target_count; Target[target_count]* targets; // TODO application statuses // TODO definition of how task statuses should be merged? ); } namespace View { typedef = ( count command_count, Command[command_count]* commands, count target_count, Target[target_count]* targets, // TODO definitions of task statuses? ); } namespace NestedViewTarget { typedef = ( Target base constraint(value.type = NestedView); View *view; ); } namespace CanvasTarget { typedef = ( Target base constraint(value.type = Canvas); // Hooks (CanvasRequest)(const Task*? task)* on_task_available; ()(const Task* task, const PaintRequest *req)* on_paint_request; ); } namespace Target { typedef Type = enum (NestedView, Canvas); typedef = ( Type type ); } namespace Task { typedef = ( ); }