snsei has quit [Remote host closed the connection]
<FromGitter>
<drosehn> they are all needed, because they are related to each other.
<FromGitter>
<drosehn> a @-variable is an instance variable tied to one instance of some class. Often you'll want to initialize that variable when you create the object. So you'll say `myobj = SomeClass.new(17)`, where the `17` is the initial value you want for some @-variable in that object. So the `initialize` method will pick up the value you specified on `SomeClass.new`, and put that in the @-instance variable.
<FromGitter>
<drosehn> Now that's great if the @-variable is never used outside of the object you've created (and certainly that happens). But if you **do** want to reference it or set it from somewhere outside that object, then the object must provide methods which access (or set) the @-variable.
<FromGitter>
<drosehn> if you create a `property` for some @-variable, that creates a "getter" and a "setter" method for the variable.
<FromGitter>
<drosehn> I hope that helps to show how these things are related to each other.
<miketheman>
drosehn: It does, thanks for the explanation. I think I'll try to challenge the assumption that the original implementation uses an `options` hash and merges things around. Instead I'll try using a Config class that gets passed into the initialize
<miketheman>
the `.gets` method will either block until `\n` or a predetermined number of bytes
<miketheman>
the `.receive` method appears to interact with binary messages
Philpax has quit [Ping timeout: 248 seconds]
sandelius has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
pawnbox has quit [Remote host closed the connection]
<asterite>
miketheman: I think you can use receive and then create a string out of the slice, or create a string and read into its slice (there's a String.new overload for that)
<miketheman>
asterite: I'll look at that, I guess I have to allocate a size of the slice to the max size of the expected message?
<Papierkorb>
What's needed to port Crystal to a new operating system? I'd be happy with the BoehmGC already
pawnbox has joined #crystal-lang
trapped has quit [Read error: Connection reset by peer]
<miketheman>
(side note, Ruby has `.to_f` to Time.now for higher precision, Crystal doesn't have that yet)
<miketheman>
is there any detriment to sizing the slice to much larger, i.e. max udp packet size? `message = Slice(UInt8).new(65_507)`
<miketheman>
or would I benefit from moving the `message` declaration outside of the loop?
<miketheman>
ah, if I do that I get weird overwriting behaviro
havenwood has joined #crystal-lang
havenwood has joined #crystal-lang
havenwood has quit [Changing host]
<miketheman>
Anyhow, it looks like it's doing the thing I wanted, thanks @asterite
sandelius has joined #crystal-lang
emancu has quit []
sandelius has quit [Client Quit]
miketheman is now known as miketheman_
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
LastWhisper____ has joined #crystal-lang
miketheman_ is now known as miketheman
mark_66 has quit [Remote host closed the connection]
miketheman is now known as miketheman_
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
LastWhisper____ has joined #crystal-lang
miketheman_ is now known as miketheman
<leafybasi>
I want to reduce an array to an array of named tuples, if I call "reduce([])" I am told to provide a type, "reduce([] of NamedTuple)" says its not specific enough, but "reduce([] of NamedTuple(key: String, value: Int32))" it complains when trying to add a tuple to the array within the block, I'm a little cofnused as to why...
<leafybasi>
Sorry reduce an array of strings to an array of named tuples*
<leafybasi>
Thanks for talking it through BlaXpirit
ponga has quit [Quit: Connection closed for inactivity]
<miketheman>
is there a way to control a Fiber? I want a long-lived spawn/loop until a `.stop` message is sent, and am not sure how that might look.
<miketheman>
Kind of like Ruby's Thread.kill
<leafybasi>
miketheman: if the loop responds to incoming messages you would use channels
<leafybasi>
But if it can't be blocked (while waiting) then I'm not sure
<Papierkorb>
miketheman: if it has to be a long-running fiber, you could make it check every iteration or so if a "running" bool has become `false`. Later, when Crystal supports threading, you can simply use an AtomicBool instead of a Bool for thread-safety.
pawnbox has joined #crystal-lang
<BlaXpirit>
aren't bools atomic anyway
<Papierkorb>
It should if you don't care about the memory barrier
jeromegn has quit [Read error: Connection reset by peer]
<miketheman>
it doesn't appear so - since without channels I use `sleep` to control the Fiber's long-life, and this has a jobs max
<miketheman>
unless I'm reading it wrong
vasilakisfil has quit [Quit: Konversation terminated!]
vegai has quit [Quit: Lost terminal]
kulelu88 has joined #crystal-lang
pawnbox has quit [Quit: gotta go guys.]
soveran has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
Yxhuvud has quit [Remote host closed the connection]
Yxhuvud has joined #crystal-lang
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
sandelius has joined #crystal-lang
ruby_ has joined #crystal-lang
ruby_ has quit [Client Quit]
pawnbox has quit [Remote host closed the connection]
<crystal-gh>
[crystal] ysbaddaden opened pull request #3379: Fix: use __iconv on FreeBSD to skip invalid bytes (master...core-iconv-freebsd-skip) https://git.io/vPOIt
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
snsei_ has quit [Remote host closed the connection]
snsei has joined #crystal-lang
sandelius has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<crystal-gh>
[crystal] asterite pushed 1 new commit to master: https://git.io/vPOY2
<crystal-gh>
crystal/master 4733360 Ary Borenszweig: Compiler: fixed crash related to cast between unions having tuples. Fixes #3377
<crystal-gh>
[crystal] faustinoaq opened pull request #3380: Fix named tuple (master...patch-1) https://git.io/vPO3p
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]