Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Check out my new DSL!

Name: Anonymous 2008-08-19 15:18

class SExp
  def initialize &block
    yield
  end
end

SExp.new {
  puts "IM IN A BLOCK"
  puts "IM LEAVING THIS BLOCK"
  puts "PEACE OUT!"

  SExp.new {
    puts "IM IN A NEW BLOCK NOW!"

    SExp.new {
      puts "IT'S JUST LIKE THE ALGORITHMIC LANGUAGE SCHEME"

      SExp.new {
        puts "HMA MEME FAN"
      }
    }
  }
}


It allows you to write your programs in Ruby just as if you were writing them in a SEXP based language like LISP or Scheme.

What do you guys think, will this be useful?

Name: JavaScript Fan 2008-08-19 16:10

globals = [
  '*' : function(x, y) { return x * y; }
];

Array.prototype.eval = function() {
  if(this.length <= 0) throw "[].eval()";
  var f = this[0];
  if(typeof(f) !== 'function') //For names not allowed in JS
    f = globals[f];
  if(!f)
    throw "What the fuck is " + f + "?";
  args = this.slice(1);
  for(var i = 0; i < args.length; ++i)
    if(args[i] instanceof Array)
      args[i] = args[i].eval();
  return f.apply(null, args);
}

display = alert;
function car(cons) { return cons.car }
function cdr(cons) { return cons.cdr }
function cons(first, second) { return { car: first, cdr: second } }

[display, ['*', 5, [car, [cons, 4, 4]]]].eval();
loeb = [ /*fuck it, I'm going to watch a film*/ ]


I'd do it in Ruby but JavaScript allows whitespace in between list elements, whereas I don't think Ruby does. As, Ruby is SLOW AS FUCK, but that's not really a problem.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List