Skip to content

Instantly share code, notes, and snippets.

@baroquebobcat
baroquebobcat / mirah_scope.md
Last active August 29, 2015 14:04
Mirah Scoping

Mirah Scoping and control structures

If statements

If statements don't introduce a new scope, like ruby, but they are a little tricky.

For example, if b is false in the following, what would a be?

@baroquebobcat
baroquebobcat / mirah_macro_help.md
Created June 16, 2014 04:12
Mirah Macro Help: Some macro notes

If you want to unquote the args from a block, be sure to not include the pipes.

#Correct

quote do
  `list`.each { `block.arguments` cool_thing; `[block.body]` }
end

#Wrong

@baroquebobcat
baroquebobcat / ext.md
Last active August 29, 2015 13:58
Mirah Extensions

Extension Methods

In the Mirah compiler, you can make Macros that work on std lib / predefined classes. You can't, however, do it in your own code easily at the moment. You can add macros that apply to your own types but not others. Here's some ideas for an API to change that.

Related

Questions

@baroquebobcat
baroquebobcat / sake_scheduler.rb
Last active August 29, 2015 13:56
A tool for planning sake making
# Sake Brewing Scheduler
require 'date'
def dfmt date
case date
when Date
date.strftime "%a, %b %e"
when Range
[date.first,date.last].map{|d|dfmt(d)}.join(" - ")
end
import java.util.concurrent.ArrayBlockingQueue
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.atomic.AtomicLong
queue_size = 10
queue = ArrayBlockingQueue.new queue_size, true
counts = {"A"=> AtomicLong.new, "B" => AtomicLong.new}
producerA = Thread.new do
while true
@baroquebobcat
baroquebobcat / mirah_0_1_2_notes
Created January 6, 2014 00:53
Mirah 0.1.2 release process notes
mirah 0.1.2 release highlights
- improvements to the new mirrors implementation (try it with -T)
- improvements to the new backend implementation (try it with -N)
- added better casting for methods that return primitives (754cc38f)
- =~, include? macros added to String (Thanks altamic)
- << operator added to StringBuilder
- improved line number recording in new backend
- fixed a few macro expansion related bugs
- Added Apache 2 license to gem metadata
@baroquebobcat
baroquebobcat / mirah_lambda.md
Last active January 2, 2016 04:09
Mirah Lambda Proposal

Mirah Lambda Proposal

Lambda types

  • Stabby / Lambda
  • Block
  • Nested Methods

Stabby / Lambda

$ rake gem
rm -rf build/bootstrap
mkdir -p build/bootstrap
Compiling 10 source files to /Users/nick/hacking/mirah_hacking/mirah/build/bootstrap
/Users/nick/hacking/mirah_hacking/mirah/src/org/mirah/IsolatedResourceLoader.java
/Users/nick/hacking/mirah_hacking/mirah/src/org/mirah/MirahClassLoader.java
/Users/nick/hacking/mirah_hacking/mirah/src/org/mirah/jvm/compiler/Cleaned.java
/Users/nick/hacking/mirah_hacking/mirah/src/org/mirah/jvm/types/Flags.java
/Users/nick/hacking/mirah_hacking/mirah/src/org/mirah/jvm/types/MemberAccess.java
/Users/nick/hacking/mirah_hacking/mirah/src/org/mirah/jvm/types/MemberKind.java
@baroquebobcat
baroquebobcat / symbol_curry.rb
Last active December 31, 2015 18:49
Symbol#curry, because one kind of curry just isn't enough
# add a curry method to symbol for evil/awesome symbol to proc powers.
class Symbol
def curry(n=nil)
->(*args) {
->(obj) {obj.send self, *args}
}.curry(n)
end
def call(*n)
curry.(*n)
@baroquebobcat
baroquebobcat / t.md
Last active December 30, 2015 20:49