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)
    }
}

One Reply to “The first stage of my port of pegged to Swift is successful :)”

Leave a Reply

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