Hacker News new | ask | show | jobs
by erik_seaberg 568 days ago
Hundreds of programming languages set very high expectations, which should support groundbreaking ideas like Lisp style macros and multimethods, ML style pattern matching, Prolog style search and unification, and Smalltalk style metaprogramming on runtime classes and overriding doesNotUnderstand.

I have to admit that right now it's a dynamically typed imperative language that looks a lot like Python.

2 comments

Alright I’ve built them into the language. Here’s the example code using what you asked for, as far as I understand at the moment: class Person { init(name, age) { this.name = name this.age = age }

    func doesNotUnderstand(method, args) {
        "Person " + this.name + " does not have " + method
    }
}

func greet(person: Person) { match person { {name: "Alice", age: 30} => "Hi Alice, you're 30." {name, age} if age > 18 => "Hi " + name + ", you're an adult." _ => "Hello there!" } }

macro log_call(func) { `(println("Calling " + ${func})) }

let alice = new Person("Alice", 30) log_call(greet(alice)) # Expands to println and calls greet

It’ll change over time, but had to start somewhere. I’ve got to run the cookbook through it and finish the ide for it.