Case statement not working?

31 views
Skip to first unread message

Justin Sowers

unread,
Oct 6, 2015, 10:34:49 AM10/6/15
to The Mirah Programming Language
First, let me say that I like Mirah a lot.  But, I have one issue I haven't been able to fix.  I installed Mirah via gem under jruby.  The reported version of the gem is 0.1.4 java, and mirahc --version reports Mirah v0.1.4.  However, the case statement doesn't work, generating: ERROR: expected tEnd before '        case '.  Do I need to download a newer patch?  If so, how do I apply it?
Thanks.  And keep up the good work!

J Scott Kasten

unread,
Oct 6, 2015, 10:37:07 AM10/6/15
to Mirah Mailing List
To the best of my knowledge, case/switch is still on the wish list.
You will have to do multiway if.

if

elsif

elsif

else

end
> --
> You received this message because you are subscribed to the Google Groups
> "The Mirah Programming Language" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mirah+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Nick Howard

unread,
Oct 6, 2015, 11:38:04 AM10/6/15
to mi...@googlegroups.com
Thanks for checking out Mirah.

That's right. There isn't case expression support yet. It's a little tricky to figure out how it's going to work given Mirah's constraints. For obvious cases like enums and primitive numbers, it should generate the same thing that Java does. For more complex cases, I've been thinking that having some kind of extension method or macro hook would be pretty neat.

Justin Sowers

unread,
Oct 6, 2015, 12:56:45 PM10/6/15
to The Mirah Programming Language
Thanks.  I had implemented the if..then..elsif chain as my workaround.  Thanks for the answer.  One for the wishlist, from me: calling java methods with Ruby _ names, instead of CamelCase.  If would make things more Ruby-like for me.  Also, being able to put a space between the variable and the :typeDeclaration.  My own idiosyncrasies.  Pay them little mind.  :)

Nick Howard

unread,
Oct 6, 2015, 3:19:52 PM10/6/15
to mi...@googlegroups.com
Hmm. You should be able to put a space between a variable and the type declaration. Have you run into a case where that doesn't work?

Justin Sowers

unread,
Oct 6, 2015, 3:27:49 PM10/6/15
to The Mirah Programming Language
Barfs on this:
ERROR: expected tRParen before 'title :String'
  def initialize(title :String, description:String, link:String,
                         ^^^ space between method argument and type hint (as ruby symbol)

but eats this just fine:
  def initialize(title:String, description:String, link:String,
                        ^^^ no space before type hint (as ruby symbol)

Note, at the end of the def method declaration, I can have as many spaces as I like before the method's return type hint.

Nick Howard

unread,
Oct 6, 2015, 3:53:18 PM10/6/15
to mi...@googlegroups.com
Oh, I see. The : doesn't allow for space on the left hand side. Syntax wise, I'd been thinking of them more as keyword args where the value is the type. We could make it more flexible like Scala's.

parses:  x:Type, x: Type
fails: x :Type, x : Type
Reply all
Reply to author
Forward
0 new messages