can/will mirah want to support these features?

45 views
Skip to first unread message

rogerdpack

unread,
May 30, 2011, 10:05:36 AM5/30/11
to The Mirah Programming Language
Hello all.

After using mirah for a day or two, I have a few comments/questions/
concerns if anybody has any answers for me :)

1) using $Override seems to do nothing? Bug-report worthy?

2) if I say
class X
Implements Y
end

it doesn't seem to check that it actually ends up implementing Y (is
there a issue filed on that somewhere?)

3) no for loops--is this expected, since ruby doesn't have any?

4) calling super in classes that inherit from java classes doesn't
seem to work [1] I assume bug?

5) auto-generated hashcode and toString methods. This might be
convenient [could just iterate over local variables or what not] :)

6) methods that end in ? or ! (or << method)

7) symbols at all [should they just be strings or something?]

Thanks, and sorry for the barrage.

-roger-

rogerdpack

unread,
May 30, 2011, 3:25:57 PM5/30/11
to The Mirah Programming Language
> 1) using $Override seems to do nothing? Bug-report worthy?

correction, it uses it to look up implementation methods for classes
that implement interfaces, it just doesn't check if the $Override
actually overrides anything :)

> 6) methods that end in ? or ! (or << method)

Appears that methods that end in ? or ! are "allowed" in mirah-land
(mirah code can call them, java code probably not so much--how would
one call one of those funky method names from java...?).

Also it appears that if I define the "plus operator" method mirahc
generate java code that is not compilable with javac. I assume this
is just a limitation in javac's parser, and not something that could
ever be fixed in mirah [though I guess it could just munge all
parameter names on their way in,and convert method! to methodBang or
something like that...?) [1]

Is there a way to override the == operator?

puts(('yo' + 'yo') == 'yoyo')

=> false in mirah, true in ruby. Mirah just uses the standard ==
instead of calling .equals I guess...

Thanks!
-roger-

[1]
$ cat test.mr

class B
def +(o:Object)
end
end

$ mirahc -j test.mr
$ javac B.java
B.java:3: <identifier> expected
public java.lang.Object +(java.lang.Object o) {
^

Stefan Springer

unread,
May 31, 2011, 2:01:14 AM5/31/11
to The Mirah Programming Language
> Appears that methods that end in ? or ! are "allowed" in mirah-land
> (mirah code can call them, java code probably not so much--how would
> one call one of those funky method names from java...?).

Well, "exotic identifiers" were skipped for JDK 7 (
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6999438 ,
http://blogs.oracle.com/jrose/entry/invokedynamic_in_build_123 ), but
maybe we will have them in JDK 8?

Speaking of JDK 8, with Project Coin part 2 we should have nice new
methods for collections ("bulk operations") that will make mirah feel
"more complete" (no more missing map function)...

Rib Rdb

unread,
May 31, 2011, 10:29:47 AM5/31/11
to mi...@googlegroups.com
On Mon, May 30, 2011 at 7:05 AM, rogerdpack <rogerp...@gmail.com> wrote:
Hello all.

After using mirah for a day or two, I have a few comments/questions/
concerns if anybody has any answers for me :)

1) using $Override seems to do nothing? Bug-report worthy?

Yeah, go ahead and file an issue for this.
 

2) if I say
class X
 Implements Y
end

it doesn't seem to check that it actually ends up implementing Y (is
there a issue filed on that somewhere?)

This should be a bug too.
 

3) no for loops--is this expected, since ruby doesn't have any?

you can use ruby's [for x in y] loop, but that is equivalent to using .each
 

4) calling super in classes that inherit from java classes doesn't
seem to work [1] I assume bug?

Can you give more details here?
 

5) auto-generated hashcode and toString methods.  This might be
convenient [could just iterate over local variables or what not] :)

6) methods that end in ? or ! (or << method)

Yeah, we should eventually support these.  I've been using macro aliases to workaround this in my classes:

macro def foo?
  quote { isFoo }
end
 

7) symbols at all [should they just be strings or something?]

Symbols are just strings.

rogerdpack

unread,
Jun 1, 2011, 7:58:54 AM6/1/11
to The Mirah Programming Language
> macro def foo?
>   quote { isFoo }
> end

interestingly, when I use mirahc --java with this macro, it still
outputs "foo?" (in error) in the java code. I'd imagine this is a bug?

Roger Pack

unread,
Jun 1, 2011, 9:11:48 AM6/1/11
to mi...@googlegroups.com
> Can you give more details here?

Oops forgot the link:

import java.util.ArrayList;

class yo extends ArrayList {
yo(java.util.List o) {
super();
}
}

compiles, but this mirah:

import java.util.ArrayList

class A < ArrayList
def initialize(o:java.util.List)
super
end
end


does not:
...
Mirah::InternalCompilerError: No constructor
java.util.ArrayList(Type(java.util.List))

>> 7) symbols at all [should they just be strings or something?]
>
> Symbols are just strings.

$ mirah -e "a = :a_symbol"
Inference Error:
DashE:1: Cannot find class a_symbol

Thanks!
-r
-roger-

Roger Pack

unread,
Jun 1, 2011, 9:14:19 AM6/1/11
to mi...@googlegroups.com
> puts(('yo' + 'yo') == 'yoyo')
>
> => false in mirah, true in ruby.  Mirah just uses the standard ==
> instead of calling .equals I guess...

I assume mirah "should" call .equals when comparing objects, by
default...unless that is deemed too mungey or what not, I think that
is almost always what people want/mean.
-roger-

Michal Hantl

unread,
Jun 1, 2011, 12:08:37 PM6/1/11
to mi...@googlegroups.com
+1

--
S pozdravem, Regards
Michal Hantl

tel: +420 777 812 167
gtalk: michal...@gmail.com
skype: michal.hantl

Robert Fischer

unread,
Jun 2, 2011, 10:20:01 AM6/2/11
to mi...@googlegroups.com
+1, especially since the first line of .equals is almost always:

if(this == them) return true;

~~ Robert.

rogerdpack

unread,
Jun 3, 2011, 10:51:53 AM6/3/11
to The Mirah Programming Language
Ok filed issues for the other feature requests/bugs.
Anybody know if this is a bug, above?


> you can use ruby's [for x in y] loop, but that is equivalent to using .each

Is it possible to use a "for x in y loop" to do the equivalent of
for(int x = 0; x < 1000; x++) ?

Also does mirah support ranges?

Thank you!
-roger-

Michal Hantl

unread,
Jun 3, 2011, 1:03:03 PM6/3/11
to mi...@googlegroups.com
Why not do (a..b).each { |i| ... } or n.times { |i| ... }?

For loop seems very un-ruby like ad counter expressive to me.

--

Roger Pack

unread,
Jun 3, 2011, 3:11:31 PM6/3/11
to mi...@googlegroups.com
> Why not do (a..b).each { |i| ... } or n.times { |i| ... }?
>
> For loop seems very un-ruby like ad counter expressive to me.

That's true for loop is not very ruby-esque.
Range don't seem to work for some reason. I ended up using a while
loop which...at least it worked :)
-roger-

Reply all
Reply to author
Forward
0 new messages