Daniel's Stuff

I write code

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

1 comment for “The first stage of my port of pegged to Swift is successful :)

  1. dendad51
    June 18, 2014 at 8:57 pm

    I’ll take your word for that.
    Probably I should stick to solder…

Leave a Reply

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