- Finish closures
- wrap new closure implementation so that this isn't an issue: mirah/mirah#276
- stabby lambdas
- potato: add to parser w/ compiler error
- non-local return
- potato: just disallow return inside blocks converted into closures that aren't lambdas
- nested bindings: they should work nicely
- Java 8 MetaLambdaing when targeting 8. It'd be cool if we could use Java 8's lambda impl when on 8
class A(object): | |
def __getattr__(s,i): | |
raise Exception('wth') | |
def raises(self): | |
"aoeu".nonexistent | |
@property | |
def yep(self): | |
self.raises() | |
A().yep |
macro def self.protected(methods_proxy:NodeList) | |
__straw_man__.expanded_children(methods_proxy).each do |c| | |
next unless c.kind_of? MethodDefinition | |
__straw_man__.add_modifiers_to(c, access: 'PROTECTED') | |
end | |
end |
Extensions are the way that Mirah adds methods to existing classes. When you call methods like each on collections, you are actually using extensions. They are helpful when you want to write DSLs and when you want to make a library you are using feel more Mirah-ish.
How do you use them?
Mirah comes with a number of built in extensions for Java's base types. For example, the methods each
, map
and empty
are added to Collection
s. The built in extensions need no special invocation to be taken advantage of, they're already available. If you want to use extensions from a library, or optional extensions, you'll need to tell Mirah which ones you want to use.
The way you do that is by "using" the extension. using
works just like import, but instead of making an imported class available, they extend other classes. For example, say you wanted to pluralize a string using an activesupport-like library. You could do it like so:
export NOTIFY_TIME=10 | |
function timer_start { | |
previous_command=$this_command | |
if [ "$BASH_COMMAND" != "timer_stop" ] | |
then | |
this_command=$BASH_COMMAND | |
fi | |
timer=${timer:-$SECONDS} |
class Dynamical | |
define_method :works_fine do |&block| | |
5.times { |n| block.call(n) } | |
end | |
def self.defn name | |
define_method name do |&block| | |
5.times { |n| yield n } | |
end | |
end |
package cool.extensions | |
extension StringExt[String] | |
def toInt | |
Integer.parseInt(self) | |
end | |
end | |
# or, less overloaded w/ generics |
constants work by being translated into field accesses / assigns.
to ensure that constants that are seen before they are assigned can be resolved, the mirror typer keeps a hash of fields that it has seen, but haven't been assigned or declared yet.
Runtimeless JVM language that tries as hard as possible to feel like writing Ruby without cheating.
- Should produce class files that are drop in replacements for Java.
- Should interop well with Java and Java tools
- It'd be nice if it interopped well with JRuby too, as well as other JVM langs, through compiler extensions.
- It should have an extensible compiler