::Myco::BasicObject << {

# Basic conditional handling
if:     |cond, &blk| cond && blk.call
unless: |cond, &blk| cond || blk.call
case: |input, *rest| {
  # If there is a final strategy with no test value, use it as the else case
  use_strategy = rest.size.odd? && rest.pop
  # Iterate over the pairs of test_values and strategies,
  # selecting the first matching pair's strategy as the one to use.
  rest.each_slice(2).detect |test_value, strategy| {
    (test_value == input) && (
      use_strategy = strategy
      true
    )
  }
  # Call or return the selected strategy or error if none
  use_strategy &? (use_strategy.?call(input) ?? use_strategy)
               ?? raise("No match for case("input")")
}
cond: |*rest| {
  # If there is a final strategy with no test value, use it as the else case
  use_strategy = rest.size.odd? && rest.pop
  # Iterate over the pairs of test_values and strategies,
  # selecting the first matching pair's strategy as the one to use.
  rest.each_slice(2).detect |test_value, strategy| {
    (test_value.?call ?? test_value) && (
      use_strategy = strategy
      true
    )
  }
  # Call or return the selected strategy or error if none
  use_strategy &? (use_strategy.?call ?? use_strategy)
               ?? raise("No match for cond")
}

switch: |input,comparator=:"=="| # TODO: remove deprecated switch
  Switch.new(input:input, comparator:comparator)

# TODO: alias more efficiently
# alias(::Ruby::Kernel, :raise) raise
# alias(::Ruby::Kernel, :loop) loop
raise: |*args| ::Ruby.__send__(:raise, *args)

# TODO remove deprecated aliases after 0.1.9 is released
loop: |&block| Loop.run(&block)
break:         Loop.break

send: |*args, &block| __send__(*args, &block)

kind_of?: |mod| __kind_of__(mod)
is_a?:    |mod| __kind_of__(mod)

class: __class__ # TODO: consider removing

dup: __dup__ # TODO: remove

puts: |*args| STDOUT.puts(*args)
p:    |*args| STDOUT.puts(args.map |a| { a.inspect }.join(', '))

ruby_require: |arg| ::Ruby.send(:require, arg)

}