in reply to returning an object in XS

   rect r(minx,miny,maxx,maxy);

What language is that?

It doesn't look like valid C to me? r() is a function taking 4 doubles, but what is the rect prefix doing?


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?

Replies are listed 'Best First'.
Re^2: returning an object in XS
by ikegami (Patriarch) on Feb 29, 2012 at 07:21 UTC
    It's C++, not C.
      It's C++,

      It still doesn't look like any syntax I'm familiar with? It's been a while since I did any serious C++, but even so?


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      The start of some sanity?

        It's a variable declaration with an initialiser.

        $ cat a.cpp #include <stdio.h> struct Point { Point(int a_x, int a_y) : x(a_x), y(a_y) {} int x; int y; }; int main() { Point point(5,6); printf("%d,%d\n", point.x, point.y); return 0; } $ g++ -o a a.cpp && a 5,6

        It's like new, but the object is allocated on the stack instead of the heap, and the variable is a reference instead of a pointer. It's the object equivalent of

        int i = 5;

        which can also be written as

        int i(5);

        which is what allowed me to write

        Point(int a_x, int a_y) : x(a_x), y(a_y) {}

        instead of

        Point(int a_x, int a_y) { x = a_x; y = a_y; }
Re^2: returning an object in XS
by bipham (Novice) on Feb 29, 2012 at 04:20 UTC

    Hi BrowserUK, that was just my class rect constructor. I didn't put it in the code. I'm sorry

      that was just my class rect constructor.

      Is that a macro?


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      The start of some sanity?