These are chat archives for cortoproject/corto

Jul 2015
Sander Mertens
Jul 06 2015 02:08
The example you provide is not valid. You can't assign "null" to an object.
In C code, the equivalent of what you are trying to do in that example is:
struct Point { ... };
static struct Point a = NULL; // Doesn't work
Johnny L.
Jul 06 2015 02:43
But that example is for a value type, is it the same for reference types?
Sander Mertens
Jul 06 2015 02:44
Yes. Objects are always assigned by value. It doesn't make sense to assign them by reference because they ARE the things that one can refer to.
Consider the following

in cortex scripting (Point is a reference type):

Point p: 10, 20
Point q: 30, 40
p = q

Even though p and q are of a reference type, clearly they have to be assigned by value. I can still resolve 'p' after running this script. q did not 'magically' replace p here.

Johnny L.
Jul 06 2015 02:50
Okay! I wasn’t sure. I remember some nuances about assignments with reference types, i.e. the value is copied, the reference is not replaced.
Sander Mertens
Jul 06 2015 02:51
Yes. The easiest way to remember is that objects are always assigned by value.
Johnny L.
Jul 06 2015 16:52
How do I get the size of a type? E.g. cx_typeof(int64object)->size(?) == 8
Oh, wait; maybe I don’t need that
Sander Mertens
Jul 06 2015 18:42
No, you won't need that.
I'm not sure what you're trying to do, but pretty confident you won't need it :p
Johnny L.
Jul 06 2015 21:03
(lldb) up
frame #5: 0x00000001004c443a`test_Suite_assertEqual_any_any(_this=0x000000010061e688, a=cx_any at 0x00007fff5fbfe1c0, b=cx_any at 0x00007fff5fbfe1d8) + 90 at test_Suite.c:48
   45      /* ::cortex::test::Suite::assertEqual(any a,any b) */
   46      cx_bool test_Suite_assertEqual_any_any(test_Suite _this, cx_any a, cx_any b) {
   47      /* $begin(::cortex::test::Suite::assertEqual(any a,any b)) */
-> 48          return test_Suite_assertEqual_any_any_string(_this, a, b, NULL);
   49      /* $end */
   50      }
(lldb) down
frame #4: 0x00000001004c44b1`test_Suite_assertEqual_any_any_string(_this=0x000000010061e688, a=cx_any at 0x00007fff5fbfe170, b=cx_any at 0x00007fff5fbfe188, errmsg=0x0000000000000000) + 97 at test_Suite.c:61
   58          cx_string aS, bS;
   59          char *assertmsg;
   60          int length;
-> 61          eq = cx_type_compare(a, b);
   62          cx_valueValueInit(&aV, NULL, a.type, a.value);
   63          cx_valueValueInit(&bV, NULL, b.type, b.value);
   64          aS = cx_valueToString(&aV, 0);
(lldb) p a
(cx_any) $10 = {
  type = 0x00000001000c0440
  value = 0x00000001004dd855
  owner = '\0'
(lldb) p b
(cx_any) $11 = {
  type = 0x00000001000c0440
  value = 0x000000010061ffb0
  owner = '\0'
For some reason, cx_type_compare fails, but I’d understand that both any’s have the same type… it’s literally the same memory address.