<jeromegn>
BlaXpirit: so you're saying there are no easy way to represent a Float64 as little-endian in bytes
<jokke>
jhass: can you explain "record" to me?
<jokke>
i couldn't find any docs for it
<jokke>
you use it as a wrapper in the html headers
<willl>
"The standard library provides a useful `record` macro that allows you to create immutable structs with some fields, similar to a `Tuple` but using names instead of indices."
<crystal-gh>
[crystal] will opened pull request #1466: add Class#cast macro for runtime "as" casting (master...as-cast) http://git.io/vZXLC
leafybasil has quit [Remote host closed the connection]
<dzv>
is it possible to receive from a channel with a timeout?
<crystal-gh>
[crystal] technorama opened pull request #1468: Inherit write buffer setting on new socket in Socket.accept. (master...f/http_server_enhancements) http://git.io/vZ1EX
elia has quit [Quit: (IRC Client: textualapp.com)]
elia has joined #crystal-lang
maxdeviant has quit [Ping timeout: 246 seconds]
<crystal-gh>
[crystal] jhass opened pull request #1469: Correctly handle signal exits in crystal run (master...fix_run_signal_handling) http://git.io/vZ1yG
Ven has joined #crystal-lang
jeromegn has joined #crystal-lang
Neverdie has joined #crystal-lang
<crystal-gh>
[crystal] jhass closed pull request #1468: Inherit write buffer setting on new socket in Socket.accept. (master...f/http_server_enhancements) http://git.io/vZ1EX
<jhass>
http://carc.in/#/r/fa8 but I wouldn't recommend that at all. If a module depends on a type var it should be explicitly forwarded, like Enumerable does for instance
Regexident has joined #crystal-lang
<dzv>
i'm reluctant to require a type for Iterable.
Neverdie has joined #crystal-lang
<dzv>
unless you think the change would be approved
<jhass>
better than assuming the type var has a special name
<jhass>
implicit coupling is worse than explicit coupling
<jhass>
if you have a good reason ...
<dzv>
comparable
<jhass>
you'll need a few more words than that. In your PR
<dzv>
#1452
<dzv>
waj is concerned about overhead. i'm attempting to optimize but i need access to T
havenwood has joined #crystal-lang
<jhass>
I think he also pointed out that we can't assume we can memcmp just because it's not a container type
<jhass>
since container types may specify a == that would allow it and non-container types may specify one that doesn't
<dzv>
yes, so i'm going to optmize for Number types or possibly just int's
<dzv>
which covers the common case of comparing 2 binary strings or occassional arrays of ints
<jhass>
might be a lot easier to just provide overloads there
<dzv>
is that possible. i can only optimize when Array(T == Int) and ==(other) is the same type
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<jhass>
I see Ary is listening :P
<asterite>
Hehe, we noticed it didn't work some days ago, and now it was mentioned again
<jhass>
ah, fake away!
Ven has joined #crystal-lang
<dzv>
is there any way to see if T is a number in a macro? {% if Number === T %} doesn't work
<asterite>
No
<dzv>
jhass: byte by byte comparisons will always be slower than calling memcmp
<asterite>
But you can do if T.is_a?(Number.class)
<asterite>
but note that this won't work, BigInt is a Number and you don't want memcpy there
<asterite>
You'll have to do it for specific primitive types
<dzv>
at this point i'll compare UInt8 only and leave the rest alone
<asterite>
I'd try to avoid these optimizations now, we can always do them later. Right now they will make the code a bit uglier and it's no bottleneck so far
<asterite>
You can then do `if T.is_a?(UInt8.class)`
<asterite>
In all cases that check will be gone because T is known at compile time
<jhass>
asterite: in any case we do need to do something about <=>/Comparable. Having PartialComparable shows that something is broken in the design
<asterite>
Mmm... why?
<asterite>
Not all objects are comparable
<dzv>
all objects can be PartialComparable
<asterite>
I don't want `1 <=> false` to compile
<asterite>
Then you can do `[1, 2, false].sort` and it will raise at runtime
<asterite>
instead of at compile time
<asterite>
That's the main reason
<dzv>
by default restrict <=> to same type but still define it as the single interface for all other comparisons. other types could include Comparable when they want the other operators to work. rename <=> to some internal name if you don't ant it to work by default
<dzv>
my issue is that you may need to override multiple methods and they are starting to conflict
<jhass>
I think having both Comparable and PartialComparable is plain confusing
<jhass>
I haven't made up a strong opinion on how, but I do think we need to get rid of one variant
thor77 has left #crystal-lang ["Leaving"]
<asterite>
PartialComparable was introduced along with the compiler tools for IDE. I was kind of against it because maybe things can be done in another way
<dzv>
and regardless of which is picked i think there should be a single method from which all comparisons are based. make it some internal name rather than <=> if need be. def compare(other)
<asterite>
However, partial order is a mathematical thing
<jhass>
it's impossible to understand the differences currently from them
<dzv>
asterite: is there a quick match for if T is a int or float but not general number (like a bigint)
<jeromegn>
apparently, if I subclass String, and then add that class to an alias type (along with String) (ie: alias Type = String | StringLike | Int32), the String is not present anymore in there... like: http://play.crystal-lang.org/#/r/fab
<jeromegn>
and so I'm getting compile errors because String is not in there!
<nakilon>
from some github comments: "deprecated def foo(bar), "use X instead""
<nakilon>
I'm thinking about adding such warnings when some warnings flag enabled
<nakilon>
warnings could cover such things as "Crystal for Rubyists" wiki page
<diegoviola>
my code just compiled with crystal... cool
<diegoviola>
so is crystal a new language or it can be seen as just another ruby vm?
<BlaXpirit>
diegoviola, no, definitely a separate language
<BlaXpirit>
with very different concepts
dfockler has joined #crystal-lang
<jeromegn>
BlaXpirit: fyi, I ended up just doing: n = self; Slice(UInt8).new(pointerof(n) as UInt8*, 8); to get the bytes for my Float64. seems to work fine (both ways, parsing and serializing)
ssvb has quit [Ping timeout: 272 seconds]
<jeromegn>
I know this was discouraged, but that's the only way I found
<BlaXpirit>
i don't have anything else to suggest
<BlaXpirit>
might as well use this for every data type then
<jeromegn>
could I just shift the bytes from that Slice to ensure little-endianness?
<BlaXpirit>
you could detect whether the system is big endian and reverse the bytes in that case
<jhass>
I guess the {} are just a common habit to make it more recognizable
<jhass>
(you can put them around any var)
<crystal-gh>
[crystal] asterite closed pull request #1293: Allow to run programs through a shell receiving huge argument lists (master...shell_args) http://git.io/vGe1U
<diegoviola>
asterite: hola, ustedes son de Argentina?
<asterite>
diegoviola: hola. Sí, vos también?
<diegoviola>
asterite: no, soy de Paraguay ^_^
ylluminate has joined #crystal-lang
<jeromegn>
getting a bit of a cryptic error trying to modify a Hash(String, TonsOfTypes). when I hash["something"] = Array, I get an error: no overload matches 'BSON::Document#[]=' with types String, Array(BSON::Document)
<jeromegn>
Overloads are:
<jeromegn>
- BSON::Document#[]=(key : K, value : V)
<jeromegn>
I mean, when I do hash["something"] = some_array
<jeromegn>
however, BSON::Document is a subclass of Hash(String, BSON::ValueType)
<crystal-gh>
[crystal] asterite pushed 3 new commits to master: http://git.io/vZSIk
<jhass>
asterite: I've been thinking, I think we should mark RFCs we'd like to see implemented and which need discussion still. Rejected ones are closed, easy enough. What about a draft and accepted label for the other two states?
<jhass>
jsaak: because when we tried to infer the type it was really really slow
<jsaak>
ohh ok, that sound reasonable
<jhass>
jsaak: you'd need to track the entire objects life and then when you're sure you got all instances (which is already quite hard) you need to trace back and annotate the type
<jhass>
then you get easier unions by mistake (like mixing hash and string keys because the other variant is out of sight) and then you wonder why it doesn't work and that also slows down the generated program
<jsaak>
i do have a command line program, which has about 20 command line parameters, some bools, some strings, some arrays
diegoviola has quit [Quit: WeeChat 1.3]
<jsaak>
and i want to make these wisible accross multiple classes
<jsaak>
i tried globals vars, encampusalating them in a class,a big hash, but all of these did not work very well
<jsaak>
the big problem is that all of them can be Nil
<jsaak>
i have to make a local variable, and put it the logic inside an if