Dechenjm / crack-language

Automatically exported from code.google.com/p/crack-language
Other
0 stars 0 forks source link

Overloading in modules not working #51

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
For version fb8085101b2a

This is probably a known issue:

In module math.crk I have a n overloaded max() function as follows:
int max(int v1, int v2){
  if (v1>v2) return v1;
  return v2;
}

float max(float v1, float v2){
  if (v1>v2) return v1;
  return v2;
}

I get an error when importing the module:
Cannot reference function max because there are multiple overloads.

Generics would probably help here :-)

Original issue reported on code.google.com by Conrad.S...@gmail.com on 26 Oct 2010 at 12:34

GoogleCodeExporter commented 9 years ago
Scratch that, the error happened in a cout:
cout `max=$max(1,2)`;

FWIW, the ruby or C#, or even C printf syntax works very well for this:
"#{max(1,2)}" - ruby
"{1}",max(1,2) - C#

I.e. the `` operator might need a delimeter to recognize the start and end of 
the format expression.

Original comment by Conrad.S...@gmail.com on 26 Oct 2010 at 12:42

GoogleCodeExporter commented 9 years ago
does "cout `max=$(max(1,2))`;" work for you?

Original comment by mind...@gmail.com on 26 Oct 2010 at 10:38

GoogleCodeExporter commented 9 years ago
Yes, that works

Original comment by Conrad.S...@gmail.com on 27 Oct 2010 at 7:03

GoogleCodeExporter commented 9 years ago
confirmed that this works; closing.

Original comment by mind...@gmail.com on 27 Oct 2010 at 7:40

GoogleCodeExporter commented 9 years ago

Original comment by mind...@gmail.com on 18 Jan 2011 at 4:13