<jhass>
manveru: maybe a busy loop so the signal fiber can never run?
<FromGitter>
<manveru> I think my terminal was busted. Tried it in a fresh one and it worked just fine
<FromGitter>
<manveru> I don't have a single other thread or fiber or process going on
_whitelogger has joined #crystal-lang
postmodern has joined #crystal-lang
<postmodern>
how do people normally implement Iterator and Enumerable classes? Do you implement the logic in an Iterator and instantiate your iterator instance in the Enumerable classes #each method in order to re-use the logic?
oddp has joined #crystal-lang
<oprypin>
postmodern, people normally don't
<oprypin>
regarding the latter question, yes, that's how to do it
<jhass>
stdlib often chooses to implement it twice as you may choose different trade-offs for either implementation in terms of perfomance vs storage requirements
<jhass>
also some Iterator can't be struct, so reimplementing can save a heap allocation
<jhass>
but then that's stdlib trying to be optimized
<FromGitter>
<j8r> I thought `IO::Memory#close` will kind of free memory, but that's not the case
<FromGitter>
<j8r> that will be the GC. The only purpose is to avoid further write to the IO.
<jhass>
Yeah, if you want manual memory management, Crystal is not your language ;)
<FromGitter>
<j8r> WebSocket or WebSocket::Protocol does not inherit from IPSocket, that's normal?
<FromGitter>
<j8r> (or just Socket)
<FromGitter>
<j8r> I guess that's because it is too special
<jhass>
I guess it's because it's frame oriented rather than stream oriented
<jhass>
but maybe it's just whoever designed the API was already too caught up in its implementation details 🤷
<jhass>
if you can demonstrate a sensible implementation exposing the IO interface, that'd be a lovely shard for sure
<jhass>
it's not like it's not replacable
_whitelogger has joined #crystal-lang
<FromGitter>
<stellarpower> Hey, what would be the best way of doing the equivalent from Ruby: `myObject.send(:hello)`?
<FromGitter>
<stellarpower> The only idea that comes to me is using a macro on the list of things that I want to call, which would work fine, but for fututre reference would be goot to know what's possible
deavmi has quit [Ping timeout: 256 seconds]
<FromGitter>
<Blacksmoke16> Probably best to rethink the design so you don't need to do that
postmodern has quit [Quit: Leaving]
<FromGitter>
<stellarpower> I'm comparing two File::Infos for similar permissions, owner, group, etc.
<FromGitter>
<stellarpower> So was going to run through all the methods on them and check they're equal or not for both files
<FromGitter>
<stellarpower> I was writing a macro using icr but it just got messy, IDK if there's a way I can see what a macro invocaion is turned into as that would help
<FromGitter>
<Blacksmoke16> cant just implement a `def ==(other : File::Info)`?
<FromGitter>
<stellarpower> Yeah that's what I'm doing
<FromGitter>
<Blacksmoke16> are you expecting this to return true if left and right are the same file?
<FromGitter>
<Blacksmoke16> and false otherwise
<FromGitter>
<stellarpower> It's to check a recursive copy
<FromGitter>
<stellarpower> It comes up so often and I wanted to write a proper script
<FromGitter>
<stellarpower> And false if permissions have changed for example
<FromGitter>
<stellarpower> so it would be true if left and right are identical but in different locations
<FromGitter>
<Blacksmoke16> to be clear i meant define that method within `File::Info`
<FromGitter>
<Blacksmoke16> then can just do `left == right`
<FromGitter>
<stellarpower> Yeah I may do, I've just left it free for now, I was going to look up how ot do operator overloading properly once it worked
<FromGitter>
<stellarpower> It's just it's ugly, and that's precisely why we have macros
<FromGitter>
<stellarpower> I can give it a list of methods that I want to compare and ignore e.g. timestamps
<FromGitter>
<Blacksmoke16> considering you just have to define it once, macros are prob not worth it
<FromGitter>
<Blacksmoke16> other option would be like
<FromGitter>
<stellarpower> Yes good idea, I wanted a learning exercise so I was trying to use the ArrayLiteral#reduce rather than implementing myself and it got complicated
<FromGitter>
<stellarpower> Ill look and see if I can get the compiler to output what it's doing with a macro as that will help
<FromGitter>
<stellarpower> Oh that's a macro itself - debug(?)
<FromGitter>
<stellarpower> What I'm trying to do cause I never find a single command that does this when I need it
<FromGitter>
<stellarpower> Actually I could nicely reduce the desired properties to an array and remove the intersection and print that
HumanG33k has joined #crystal-lang
<FromGitter>
<stellarpower> I'll put it on github once it's tidied up a bit, just seeing if it works properly now
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
<FromGitter>
<j8r> oprypin jhass what would you suggest as an opposite operation to convert Bytes (which represents a UInt8 and after a Float32) to a UInt8 and a Float32?
<FromGitter>
<j8r> I was using `Slice[Range]` with `IO::ByteFormat`, but maybe there is a better way...
<FromGitter>
<j8r> Ho nvm there is `IO::Memory#read_bytes`
<FromGitter>
<Blacksmoke16> should be inherited from `IO` no?
<jhass>
yeah, and depending on where get your `Bytes` from, no need to proxy it to `IO::Memory` first. Also iirc there should be an overload to initialize an IO::Memory to some specific Bytes, if not we totally should add it
<FromGitter>
<j8r> we can encode and decode with `.from_io` and `#to_io`
<FromGitter>
<j8r> ha, not the `encode to bytes` part
<FromGitter>
<j8r> can be solved by adding a new unsafe method to Float/Int
<FromGitter>
<j8r> ... the `#to_io` and `.from_io` are just shortcuts
_whitelogger has joined #crystal-lang
<FromGitter>
<j8r> TIL `'use strict'` in JS
<FromGitter>
<j8r> Kind of Shell's `set -eu`
<raz>
yup, both promise sanity and stab you in the back a day later
<oprypin>
j8r, it's really not.. it's like declaring that you acknowledge "javascript 2.0"
<FromGitter>
<stellarpower> What do folks think would be the closest alternative languages to Crystal in terms of balancing the ease of writing with the strong typing and still using a compiler? There are so many that have shot up recently and yet people often still stick to old-fashioned compiled stuff or dynamic languages like Python, I'm curious which others if any have taken the same approach cause I'm not sure I know of anything
<FromGitter>
... comparable.
<oprypin>
@stellarpower: c++
<FromGitter>
<RespiteSage> "ease of writing"?
<FromGitter>
<RespiteSage> Or is that just the closest (even if it's not very close)?
HumanG33k has quit [Ping timeout: 260 seconds]
HumanG33k has joined #crystal-lang
<FromGitter>
<stellarpower> Do you think? C++ was my first languages as it happens so I often find myself comparing back.
<FromGitter>
<stellarpower> Guess when I say ease of writing I mean quite high-level and expressive
<FromGitter>
<stellarpower> Writes like a script, compiles with safety like C
_whitelogger has joined #crystal-lang
<yxhuvud>
safety like C? That is like running with scissors.
<sorcus>
:-D
<FromGitter>
<RespiteSage> Fun with Generics: ⏎ Method argument restriction of `Enumerable(T)`for `Tuple(X < T, Y < T)` works: https://carc.in/#/r/9duk ⏎ Method argument restriction of `Enumerable(T)` for `Tuple(X < T, X < T)` works: https://carc.in/#/r/9dul ⏎ Return type restriction of `Enumerable(T)` for `Tuple(X < T, X < T)` doesn't work: https://carc.in/#/r/9dum ⏎ Return type restriction of `Enumerable(T)` for `Tuple(X <
<FromGitter>
<RespiteSage> I'm trying to write a type to handle arbitrary derived units (like "mass * length / timespan ** 2") with generics, and I'm running up against this.
<FromGitter>
<RespiteSage> I'm assuming most of the differences there are due to the rules around when types in unions are collapsed into their shared supertypes (and the differences between method argument restrictions and return type restrictions).
<FromGitter>
<j8r> oprypin why do you say that?
<FromGitter>
<j8r> because ECMA 5 is now quite old
<oprypin>
j8r, well no why do you say that.. it's not like by default javascript ignores all errors. and then 'use script' doesn't immediately make it exit unconditionally on all errors. cuz that's what set -e does
<oprypin>
j8r, "javascript 2.0" in quotes because it is not meant as a direct relation to a real-world version
<oprypin>
you could imagine if crystal made a 2.0 release with some improvements in behavior but actually it's fully backwards compatitble with 1.0 and so has all those bad behaviors, unless you write some magic string at the top of the file
<FromGitter>
<j8r> I mean, it add security layers to an unsafe language
<oprypin>
all the changes connected to 'use strict' are changes that they wish they could retroactively put into the language by default but can't afford to
<oprypin>
im only disagreeing with the comparison to `set -e`
<FromGitter>
<j8r> not really
<FromGitter>
<j8r> the strict mode adds exception in place where errors where ignored
<FromGitter>
<j8r> in a sense, the script will exits in some places - but yeah, that's not really the same
<raz>
i just had a funky exception with lots of ???
<FromGitter>
<Blacksmoke16> :shrug:
<raz>
hm, the deeper i dig into jennifer the more impressed i am. pretty crazy a single guy (mostly?) built all that.
<raz>
doesn't look super polished from the outside, esp. the docs. but it works really solid and has all kinds of stuff covered that i haven't seen in the other ORMs yet.
<raz>
he built his own little ecosystem with separate shards for serialization, form mapping and what not
HumanG33k has quit [Ping timeout: 246 seconds]
<FromGitter>
<asterite> Benjamin Wade: all of those examples work as expected. When types are in a union they go to the closest parent (Arbitrary case) except when those types are a few specific ones, like Reference, Value, Number, Int, Float, Object.
<FromGitter>
<asterite> Maybe you could explain what you want to achieve. But in general, not putting type restrictions not return types will let you go much farther than using restrictions.
<FromGitter>
<asterite> not -> nor
<oprypin>
raz: you sound like a person who's in the right state of mind to write those docs :p
<raz>
i would love to, if only my day had 2 more hours and my bank account 4 more digits ;)
HumanG33k has joined #crystal-lang
<oprypin>
that "4 digits" just made me 🤔🤔🤔🤔🤔🤔🤔🤔🤔
<raz>
well, i'm picky, they gotta be in the right places too...
<raz>
after the comma won't help so much :D
HumanG33k has quit [Ping timeout: 256 seconds]
<FromGitter>
<RespiteSage> @asterite That's fair. I'll remove those restrictions (or make it `Tuple(Class)` for better API clarity). I'm kinda straining the generics system, I think, because I'm trying to make a `DerivedType(N, D)` where `N` and `D` are `Tuple(X < Unit)` (numerators and denominator units of the derived unit). I figured I'd need to put compile-time checks in the constructor (something I've done before) to ensure that
<FromGitter>
... `N` and `D` are well-formed, but I was hoping that having type restrictions on methods that return them could serve the same purpose.
<FromGitter>
<RespiteSage> So, for example, if you wanted a measure of force and you already have `Mass`, `Length`, and `Timespan`, you could do `DerivedUnit({Mass, Length},{Timespan, Timespan}).new(<some value>)`
<FromGitter>
<RespiteSage> And then if you wanted to have some special methods on a `Force` class, you could inherit `DerivedUnit({Mass, Length},{Timespan, Timespan})`.
<FromGitter>
<RespiteSage> At least, that's what I'm going for.
andremedeiros has quit [*.net *.split]
livcd has quit [*.net *.split]
Stephie has quit [*.net *.split]
sagax has joined #crystal-lang
HumanG33k has joined #crystal-lang
andremedeiros has joined #crystal-lang
Stephie has joined #crystal-lang
Stephie has quit [Quit: Fuck this shit, I'm out!]
Stephanie has joined #crystal-lang
oddp has quit [*.net *.split]
DTZUZU has quit [*.net *.split]
ua has quit [*.net *.split]
mjblack has quit [*.net *.split]
Xeago has quit [*.net *.split]
Flipez has quit [*.net *.split]
oddp has joined #crystal-lang
ua has joined #crystal-lang
Xeago has joined #crystal-lang
mjblack has joined #crystal-lang
DTZUZU has joined #crystal-lang
Flipez has joined #crystal-lang
sorcus has quit [*.net *.split]
sz0 has quit [*.net *.split]
lunarkitty has quit [*.net *.split]
oprypin has quit [*.net *.split]
krobin has quit [*.net *.split]
lanodan has quit [*.net *.split]
Andriamanitra has quit [*.net *.split]
straight-shoota has quit [*.net *.split]
gangstacat has quit [*.net *.split]
psydroid has quit [*.net *.split]
jetpack_joe has quit [*.net *.split]
FromGitter has quit [*.net *.split]
badeball has quit [*.net *.split]
sz0 has joined #crystal-lang
krobin has joined #crystal-lang
oprypin has joined #crystal-lang
lunarkitty has joined #crystal-lang
lanodan has joined #crystal-lang
sorcus has joined #crystal-lang
Andriamanitra has joined #crystal-lang
straight-shoota has joined #crystal-lang
jetpack_joe has joined #crystal-lang
badeball has joined #crystal-lang
psydroid has joined #crystal-lang
gangstacat has joined #crystal-lang
FromGitter has joined #crystal-lang
rocx has quit [*.net *.split]
chachasmooth has quit [*.net *.split]
woodruffw has quit [*.net *.split]
oz has quit [*.net *.split]
bougyman has quit [*.net *.split]
snapcase has quit [*.net *.split]
psydroid has quit [Max SendQ exceeded]
chachasmooth has joined #crystal-lang
snapcase has joined #crystal-lang
woodruffw has joined #crystal-lang
bougyman has joined #crystal-lang
oz has joined #crystal-lang
rocx has joined #crystal-lang
chachasmooth has quit [Max SendQ exceeded]
chachasmooth_ has joined #crystal-lang
Vexatoast has quit [*.net *.split]
Welog has quit [*.net *.split]
olbat has quit [*.net *.split]
twosecslater has quit [*.net *.split]
davic has quit [*.net *.split]
Welog has joined #crystal-lang
davic has joined #crystal-lang
Vexatoast has joined #crystal-lang
twosecslater has joined #crystal-lang
olbat has joined #crystal-lang
sz0 has quit [Ping timeout: 260 seconds]
jetpack_joe has quit [Ping timeout: 253 seconds]
Stephanie has quit [*.net *.split]
raz has quit [*.net *.split]
csaba has quit [*.net *.split]
coderobe has quit [*.net *.split]
Elouin has quit [*.net *.split]
issyl0 has quit [*.net *.split]
raz has joined #crystal-lang
Stephanie has joined #crystal-lang
csaba has joined #crystal-lang
Elouin has joined #crystal-lang
issyl0 has joined #crystal-lang
coderobe has joined #crystal-lang
ryanprior has quit [Ping timeout: 244 seconds]
deavmi has quit [*.net *.split]
sagax has quit [*.net *.split]
Nekka has quit [*.net *.split]
early has quit [*.net *.split]
coderobe has quit [Max SendQ exceeded]
r0bby has quit [Ping timeout: 244 seconds]
hamoko[m] has quit [*.net *.split]
melthelesbian has quit [*.net *.split]
commavir has quit [*.net *.split]
Liothen has quit [*.net *.split]
kevinsjoberg has quit [*.net *.split]
deavmi has joined #crystal-lang
early has joined #crystal-lang
sagax has joined #crystal-lang
Nekka has joined #crystal-lang
hamoko[m] has joined #crystal-lang
melthelesbian has joined #crystal-lang
commavir has joined #crystal-lang
kevinsjoberg has joined #crystal-lang
Liothen has joined #crystal-lang
HumanG33k has quit [*.net *.split]
go|dfish has quit [*.net *.split]
bazaar has quit [*.net *.split]
go|dfish has joined #crystal-lang
HumanG33k has joined #crystal-lang
bazaar has joined #crystal-lang
maxpowa has quit [*.net *.split]
dom96 has quit [*.net *.split]
iwq has quit [*.net *.split]
daemonwrangler has quit [*.net *.split]
frojnd has quit [*.net *.split]
return0e[m] has quit [Ping timeout: 244 seconds]
dostoyevsky has quit [*.net *.split]
twistedpixels has quit [*.net *.split]
asterite has quit [*.net *.split]
frojnd has joined #crystal-lang
dom96 has joined #crystal-lang
maxpowa has joined #crystal-lang
iwq has joined #crystal-lang
daemonwrangler has joined #crystal-lang
dom96 has quit [Excess Flood]
dostoyevsky has joined #crystal-lang
asterite has joined #crystal-lang
twistedpixels has joined #crystal-lang
dostoyevsky has quit [Max SendQ exceeded]
HumanG33k has quit [Remote host closed the connection]
skrzyp1 has quit [*.net *.split]
justinmcp has quit [*.net *.split]
Liothen has quit [Ping timeout: 246 seconds]
r0bby has joined #crystal-lang
HumanG33k has joined #crystal-lang
dostoyevsky has joined #crystal-lang
f1reflyylmao has quit [*.net *.split]
jhass has quit [*.net *.split]
repo has quit [*.net *.split]
DeBot has quit [*.net *.split]
Seich has quit [*.net *.split]
antoszka has quit [*.net *.split]
fifr has quit [*.net *.split]
justinmcp has joined #crystal-lang
skrzyp1 has joined #crystal-lang
dom96 has joined #crystal-lang
hamoko[m] has quit [Remote host closed the connection]
repo has joined #crystal-lang
f1reflyylmao has joined #crystal-lang
jhass has joined #crystal-lang
DeBot has joined #crystal-lang
Seich has joined #crystal-lang
antoszka has joined #crystal-lang
fifr has joined #crystal-lang
baweaver has quit [*.net *.split]
baweaver has joined #crystal-lang
HumanG33k has quit [Read error: Connection reset by peer]
skrzyp1 has quit [Ping timeout: 265 seconds]
jetpack_joe has joined #crystal-lang
return0e[m] has joined #crystal-lang
skrzyp1 has joined #crystal-lang
HumanG33k has joined #crystal-lang
deavmi has quit [*.net *.split]
sagax has quit [*.net *.split]
Nekka has quit [*.net *.split]
early has quit [*.net *.split]
HumanG33k has quit [Remote host closed the connection]
sagax has joined #crystal-lang
Nekka has joined #crystal-lang
deavmi has joined #crystal-lang
early has joined #crystal-lang
HumanG33k has joined #crystal-lang
Liothen has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
sz0 has joined #crystal-lang
HumanG33k has quit [Ping timeout: 256 seconds]
hamoko[m] has joined #crystal-lang
psydroid has joined #crystal-lang
ryanprior has joined #crystal-lang
HumanG33k has joined #crystal-lang
<FromGitter>
<asterite> Thanks. I guess I need a few more example or code to understand what you are trying to achieve. So many generic types make it look like really complex, even more so when nested inside tuples types... is that necessary?