#define PI 3.141592654
#define WEIRDINT (1<<(sizeof(int)*8-1))
#define btoa(EXPR) ((EXPR)?"TRUE":"FALSE")
-#define coalesce(VAR,EXPR) (VAR?VAR:(EXPR))
+#define coalesce(VAR,EXPR) (VAR?VAR:(VAR=0,(EXPR)))
+#define coalesce_str(VAR,EXPR) (VAR && *VAR?VAR:((VAR=NULL),(EXPR)))
/* .----------------------------------------------------------------------.
/ 4. C<<1 data declaration and allocation, updated 2008-01-31 xCh.
'----------------------------------------------------------------------- */
#define construct(TYPE,INTERFACE) TYPE _init_##TYPE(TYPE o,INTERFACE i) { o->__interface=i; return o; } TYPE __init__##TYPE
#define get_obj(TYPE,INTERFACE,...) __init__##TYPE(_init_##TYPE(get_mem(TYPE),INTERFACE),__VA_ARGS__)
#define get_obj_as(COMMUNITY,MEM,INTERFACE,...) (COMMUNITY)get_obj(MEM,INTERFACE,__VA_ARGS__)
-#define _(METHOD,...) ((((_ARG1(__VA_ARGS__,)) || /* will not compile if object is not Lvalue: */(_ARG1(__VA_ARGS__,)=NULL)) && (_ARG1(__VA_ARGS__,))->__interface->METHOD)?(*( (_ARG1(__VA_ARGS__,))->__interface->METHOD )) ((void *)__VA_ARGS__):0)
+#define _(METHOD,...) ((((_ARG1(__VA_ARGS__,)) || /* will not compile if object is not lvalue: */(_ARG1(__VA_ARGS__,)=NULL)) && (_ARG1(__VA_ARGS__,))->__interface->METHOD)?(*( (_ARG1(__VA_ARGS__,))->__interface->METHOD )) ((void *)__VA_ARGS__):0)
#define __(METHOD,...) ( _ASSERT(ARG1(__VA_ARGS__,)), (*( __cll1_seekmethod(ARG1(__VA_ARGS__,),METHOD) )) ( __VA_ARGS__ ) )
#define call(OBJTYPE,METHOD,...) { int _N=0; OBJTYPE _OBJ; /* <-' */ while( (_OBJ=(OBJTYPE)_cll1_for_ptrs(_N++,__VA_ARGS__,NIL))!=(OBJTYPE)NIL ) _(_OBJ,METHOD); }
#define def_community(TYPE,INTERFACE) def_obj(TYPE) { INTERFACE __interface; };
print("* print()");
print("Hello","world","!");
print("* NIL");
- print("We can print",NULL,"safely.");
+ print("We can print", NULL, "safely.");
NIL="(hic sunt crocodiles)";
- print("We can print",NULL,"safely.");
- print("* coalesce():");
- print("We can",coalesce("print","everything"),"almost",coalesce(NULL,"anything"),"safely.");
+ print("We can print", NULL, "safely.");
+
+ {
+ str p = "print", a = NULL;
+ print("* coalesce():");
+ print("We can", coalesce(p, "everything"), "almost", coalesce(a, "anything"), "safely.");
+ }
+
echo("Surprisingly ->",NIL," (you can't see this)");
print("<- nothing special here.");
print("* OFS");