An extern operator: is this possible?

Hi,

Is there a way to get an externally defined operator, the same way there
are externally defined function with “mac#”?

This may be possible indirectly with the C target, with “mac#”
referring to a C macro itself assigned to an expression using an operator,
ex. “#define ADD(a,b) (a + b)” the using “mac#” for an “extern” function
which will later overload an operator (at least, I guess it may be
possible). There are no macro with most other targets, including
JavaScript, thus the question.

The reason for this question, is another different question, with a case
like this:

val test = not (0 = 0);

which gets compiled by atscc2js into this:

statmp3 = ats2jspre_eq_int1_int1(0, 0);
statmp2 = ats2jspre_neg_bool1(statmp3);

which I would like to avoid, if feasible.

You could try:

macdef not(x) = $extfcall(bool, “not”, ,(x))

I will try it. For now, I came to tell there is Closure, a JavaScript to
JavaScript compiler. It’s like a minifier, which is also able of inlining,
and the latter is important here. It’s at
Closure Compiler  |  Google for Developers . It can be used as
standalone from the command line.

You could try:

macdef not(x) = $extfcall(bool, “not”, ,(x))On Saturday, May 9, 2015 at 10:08:43 PM UTC-4, Yannick Duchêne wrote:

Hi,

Is there a way to get an externally defined operator, the same way there
are externally defined function with “mac#”?

This may be possible indirectly with the C target, with “mac#”
referring to a C macro itself assigned to an expression using an operator,
ex. “#define ADD(a,b) (a + b)” the using “mac#” for an “extern” function
which will later overload an operator (at least, I guess it may be
possible). There are no macro with most other targets, including
JavaScript, thus the question.

The reason for this question, is another different question, with a case
like this:

val test = not (0 = 0);

which gets compiled by atscc2js into this:

statmp3 = ats2jspre_eq_int1_int1(0, 0);
statmp2 = ats2jspre_neg_bool1(statmp3);

which I would like to avoid, if feasible.

Is your main concern here about performance?

I don’t really know much about the JIT compiler for JS.
But I would assume that a reasonable JIT compiler for JS
should optimize away the two function calls in this case:

statmp3 = ats2jspre_eq_int1_int1(0, 0);
statmp2 = ats2jspre_neg_bool1(statmp3);On Saturday, May 9, 2015 at 10:08:43 PM UTC-4, Yannick Duchêne wrote:

Hi,

Is there a way to get an externally defined operator, the same way there
are externally defined function with “mac#”?

This may be possible indirectly with the C target, with “mac#”
referring to a C macro itself assigned to an expression using an operator,
ex. “#define ADD(a,b) (a + b)” the using “mac#” for an “extern” function
which will later overload an operator (at least, I guess it may be
possible). There are no macro with most other targets, including
JavaScript, thus the question.

The reason for this question, is another different question, with a case
like this:

val test = not (0 = 0);

which gets compiled by atscc2js into this:

statmp3 = ats2jspre_eq_int1_int1(0, 0);
statmp2 = ats2jspre_neg_bool1(statmp3);

which I would like to avoid, if feasible.