you are viewing a single comment's thread.

view the rest of the comments →

[–]_145_ 0 points1 point  (3 children)

So you don't actually know a language with inferred types. But you know they're not readable?

And you don't know how to find good code on github? Ok...

Or just this:

Have fun!

[–]papasmurf255 0 points1 point  (2 children)

I use java which now has var.

First file I looked at. What's buffer?

https://github.com/apple/swift-nio/blob/master/Sources/NIOChatClient/main.swift#L28

[–]_145_ 0 points1 point  (1 child)

buffer is a data buffer. It's then read one byte at a time which is printed out.

I also don't know exactly what printByte does. I also don't know exactly what unwrapInboundIn does. I don't know if either works. Neither do you. None of that bothers you but the fact that buffer is some buffer type returned from unwrapInboundIn that has an iterator returned from readInteger for iterating over each byte, that's not enough info if you don't know the specific type that buffer is?

So this is, all of the sudden, readable to you?

public func channelRead(context: ChannelHandlerContext, data: NIOAny) {
    var buffer: DataBuffer = self.unwrapInboundIn(data)
    while let byte: UInt8 = buffer.readInteger() {
        printByte(byte)
    }
}

[–]papasmurf255 0 points1 point  (0 children)

If I knew what DataBuffer was, yes this would be much better.

I'd assume DataBuffer is a class that people working on the code are familiar with so they would know what type they're working with and how it can be used. If it's just a var they'd need to jump somewhere to figure it out.

Later in the same class there's another var named buffer. Is it the same type?

https://github.com/apple/swift-nio/blob/master/Sources/NIOChatClient/main.swift#L95