The first stage of my port of pegged to Swift is successful :)

I have managed to get the Objective-C version of pegged to spit out a parser using Swift rather than Objective-C 🙂

It’s getting late, so I really should get some sleep.

I finally figured out what was causing the compiler to crash.  The following code will crash the Swift compiler unless the inout parameter to the block type is removed.

typealias MathFunction = (a: Double, b:Double, inout x:Int) -> Double
var counter = 0
class Executor {
    var fn: MathFunction
    init(fn: MathFunction) {
        self.fn = fn
    }
    func execute(a: Double, b: Double) -> Double {
        return fn(a: a, b: b, x: &counter)
    }
}

Join the Conversation

1 Comment

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.