<oprypin>
i have Arch on all my systems do I was able to copy stuff
<oprypin>
so*
<Paulos33>
I try to compile even a simple hello world and its out of memory
<oprypin>
you need a comparable OS in terms of library versions and compiler versions
<oprypin>
hmm that's strange
<oprypin>
are you sure it's 1GB? :p
<Paulos33>
Sucks that most cheap vps' don't use arch
<Paulos33>
It says 1.5gb available but I dunno
That_Guy_Anon has quit [Ping timeout: 260 seconds]
<FromGitter>
<bew> @RX14 about #5743, and the `popcount` thing you talked about in the PR I think I understand how I can use that for flags enum, but not for normal enum. Can I even use that? or do I need to rely on something else?
<FromGitter>
<bararchy> @bew yeha, it "works" in that it populates the struct but it wont figure out the endianess (figures) so not a good thing to do I guess
<FromGitter>
<bararchy> oh
<FromGitter>
<bararchy> I can read endianess
<FromGitter>
<bew> ?
<FromGitter>
<bararchy> I didn't figure out I can get correct Endianess from the io read
<FromGitter>
<bew> the endianness could be in a variable if that's what you meant
<FromGitter>
<bew> @bararchy also, made a mistake, the raise is not necessary as it already does that in read_bytes somewhere (although it is needed if you have only 1 byte to read and you use `read_byte`)
p0p0pr37 has joined #crystal-lang
<crystal-gh>
[crystal] bew opened pull request #5899: Use LibCrystalMain.__crystal_main directly (master...use-LibCrystalMain-directly) https://git.io/vx61m
<FromGitter>
<sdogruyol> Morning and have a nice week everyone 👋
Jenz has joined #crystal-lang
leucos has joined #crystal-lang
<FromGitter>
<bararchy> morning @sdogruyol :)
Jenz has quit [Quit: Lost terminal]
Papierkorb has joined #crystal-lang
<FromGitter>
<faustinoaq> Hi @sdogruyol 🙋
<FromGitter>
<faustinoaq> nice week for you as well 👍
<FromGitter>
<girng> wow, i could have just done result = {data: "123"}, instead of result["data"] = "123" i dont need to create a hash... named tuples FTW
Groogy has joined #crystal-lang
<Groogy>
Morning! o/
<Yxhuvud>
\
<FromGitter>
<girng> can i convert a tuple and strip the type definitions from it? for example: `[{4_i16, 6_i8}]` but only want [4, 6]
<Groogy>
well the types will always be there, without i16 and so it just becomes an i32
<Groogy>
do you mean you want a tuple that has any of the Int types in it?
<FromGitter>
<girng> `to_json` works , but the data is going to another method that uses `to_json`, so then i get extra `\"'s` all over
<Groogy>
arr = tup.map { |v| v.to_i } is that what you after?
<Groogy>
I mean the types will always be there so, just literal without postfix becomes i32
<Groogy>
actually can probably even write arr = tup.map &.to_i
<FromGitter>
<girng> will that be ok even if it's let a int64 one?
<Groogy>
yeah it will convert it to a i32 though
<FromGitter>
<girng> oh lol
<Groogy>
tup.map &.to_i64
<Groogy>
will convert each member to a int 64
<Groogy>
Int is a too unspecified type so it won't let you make Tuples/Arrays that contain any sort of Int
<Groogy>
you have to be specific and choose one of the subclasses of Int
<FromGitter>
<girng> well, thanks u answewered what i needed to do. i'm going to need to re-think this design a bit however
<FromGitter>
<girng> cuz i really need to take advantage of to_json because it does so much good work for me, i cannot let it go
<FromGitter>
<girng> is it bad toc ontinue to add more and more overloads to a hash?
<FromGitter>
<girng> i'm doing something wrong aint i lol
<FromGitter>
<girng> i mean, it works though... but every time i get overload error, the error tells me what i need to add, so i just do `| appendednewtypes` to the `msg_buffer` ⏎ but now, it seems like i'm creating too many...
Papierkorb has left #crystal-lang ["Konversation terminated!"]
<Groogy>
eeeeh yeah
<Groogy>
it means you keep assigning different types to it
<Groogy>
you probably want to parse it all into one common type
<FromGitter>
<girng> i don't think crystal devs intended for this to be used like that lol
<Yxhuvud>
well, that is one way to do it. You need to ask yourself what you actually want to store in that hash, and make certain the stuff you put into it is of that type
<Yxhuvud>
(or types, in case of union types)
<FromGitter>
<girng> the thing is, `to_json` gets called on msg_buffer, and the msg_buffer changes depending what the player wants (data) from the server
<Yxhuvud>
I suggest looking into JSON.mapping and to try to make a predictable structure that can be parsed without using to_json
<FromGitter>
<girng> so theres diff data coming from all my code...
<FromGitter>
<girng> returned from a db query.. a tuple, a hash, etc
<Yxhuvud>
If you can, it may be a good idea to unify the API too. That saves you from future headaches.
<Yxhuvud>
or make it into several different, more limited APIs.
<FromGitter>
<girng> well, in comparison to this one liner and an entire "predictable data structure", i guess this will just have to work cuz i have no idea how to implement that lol
<FromGitter>
<girng> but i mean, is this bad for performance? all these overloads? or is it negligible?
<Yxhuvud>
I doubt it will matter for you.
<FromGitter>
<girng> just little word cuz it's for the master game server. a lot of player classes gonna be used
<FromGitter>
<girng> my boss said he doesn't care , but i'm unfortunately my boss so.. i'm just a bit worried
alex`` has quit [Remote host closed the connection]
alex`` has joined #crystal-lang
<FromGitter>
<girng> im going to make a module DynamicTypes and put all of them in theere
<crystal-gh>
[crystal] MakeNowJust opened pull request #5901: Format: fix indentation after backslash newline (master...fix/crystal-format/indent-after-backslash-newline) https://git.io/vx67U
alex`` has quit [Ping timeout: 256 seconds]
alex`` has joined #crystal-lang
stone_ has joined #crystal-lang
<Groogy>
girng don't bother about what costs performance or not at this point
<FromGitter>
<bararchy> :) @picatz do a quick try and let me know what you think
<FromGitter>
<bararchy> I think I have a small bug somewhere, but can't figure out where
<crystal-gh>
[crystal] MakeNowJust opened pull request #5902: Colorize: abstract colors and support 8bit and true color (master...feature/colorize/abstract-color) https://git.io/vx6NT
duane has joined #crystal-lang
alex`` has joined #crystal-lang
<Groogy>
huh no idea what I did but somehow I'm crashing llvm when compiling?
<Groogy>
as far as I can tell only thing I changed is that I added a third argument to an initializer :/
<Groogy>
and now it just works?
<FromGitter>
<bararchy> XD
<Groogy>
oh know what it is, gonna see if I can get minimal example
<Groogy>
seems to be because of the generic it seems
<Groogy>
anyone recognize it if it's been reported already?
<FromGitter>
<girng> dumb question but i might as well ask it
<FromGitter>
<girng> is it possible to use `Any` as a type? and have it accept any data, like a `Variant`?
<Groogy>
you could implement Variant yourself in Crystal yeah
<Groogy>
but I wouldn't use YAML/JSON Any type for that
alex`` has quit [Quit: WeeChat 2.1]
alex`` has joined #crystal-lang
<FromGitter>
<girng> basically, i want to pass a parameter to a method and have it accept anything. that bypasses the infamous `no overload matches` error
<FromGitter>
<girng> i am willing and readingly to compile from source if need be
<Groogy>
well then just write a method without any argument types and the compiler generates it for you
<Groogy>
there's also some neat tricks with that, wait a second
<Groogy>
gah can't remember exactly where I had that but I have in some places a method that takes any argument and then a specialized one for nil to unset the thing
<FromGitter>
<girng> is it in the doc book maybe?
<Groogy>
i.e instead of checking if "is the object nil, then do this" I just have a seperate method that does that
<FromGitter>
<girng> wait, i can just pass the object by reference instead of trying to put into a hash right??
<FromGitter>
<girng> thank you, i'll take a stab at it
<FromGitter>
<girng> yah, just was thinking why am i passing data through my parameter. i should pass the object
<FromGitter>
<girng> then ues the references object to create my hash.. so i dont hav to deal with all the no overload matches errors lol
<FromGitter>
<bararchy> When the compiler compiles a program , does it create the whole binary in mem and then write it down at the end to the target path?
hightower2 has quit [Ping timeout: 248 seconds]
hightower2 has joined #crystal-lang
<FromGitter>
<girng> wow im idiot
<FromGitter>
<girng> i need to STOP creating a damn HASH = {} of Type => Type.......... i just need to use a NAMED tuple. don't have to worry about all these no overload matches.. just pass the object and create the damn named tuple, then to .to_json rofl rofl
<FromGitter>
<girng> got it all working now though, YAY!
<Groogy>
if things are becomming uncomfortable to work with then you probably doing something wrong :P
<Groogy>
applies to all programming
<FromGitter>
<bararchy> @girng it was a mistake I was doing until recently, when a type becomes too complex just create a class/struct for it
moei has joined #crystal-lang
<Groogy>
prefer to make classes and structs
<Groogy>
anything else is just primitive obsession
<FromGitter>
<j8r> The Crystal event loop is based on libevent, I see that Rust and Node.js use libuv and there is also libev. The 2 laters appear to be more efficient evolutions of libevent. Does someone have experience with them?
<FromGitter>
<j8r> I was also wondering why libevent was chosen for Crystal...
<FromGitter>
<girng> @bararchy coming from nodejs background i thought we had create a hash/key type for tuples.. lol little did i know, crystal has a damn NamedTuple built in!!!
<FromGitter>
<bew> I never managed to make it work myself, but you can use https://github.com/olbat/libgen (which uses crystal_lib under the hood iirc)
<woodruffw>
`crystal_lib` worked for me as of ~2 months ago, so it *should* still work...
<woodruffw>
how are you invoking it?
<FromGitter>
<jwaldrip> ```code paste, see link```
<woodruffw>
yeah, that looks like what i did. is it spitting out an error?
<FromGitter>
<jwaldrip> no error
<woodruffw>
:(
<FromGitter>
<jwaldrip> just spits out empty file
<FromGitter>
<jwaldrip> @[Link("tar")] ⏎ lib LibTar ⏎ end
<RX14>
@bew yeah popcount was only for flags enums
<RX14>
in macros just check if its a flag enum
<RX14>
if it is, popcount, else count unique
<woodruffw>
@jwaldrip: are you sure it's `libtar.h`? going through the libtar sources, i see references to `tar.h`
<woodruffw>
hmm, nvm, `libtar.h` exists too...
<FromGitter>
<bew> @RX14 how do I count unique for normal enum? 'can't find a simple solution..
<RX14>
not sure
<RX14>
probably have an array and spit into it if it doesn't contain it
<RX14>
I mean in macros
<RX14>
then once you have the array take it's size
<FromGitter>
<bew> problem is, from macros we don't have access to the values, only the name of each member
<RX14>
what?
<RX14>
really?
<FromGitter>
<bew> at least from `TypeNode#constants`
<FromGitter>
<bew> we 'could' make a `TypeNode#constant` for each name in `TypeNode#constants`, but we have another problem: an enum field can by an operation, so we'd need sth to eval the value, to verify we don't already have it
<RX14>
well thats just opened up a whole new can of worms
<RX14>
1) enum values should be restricted to simple numerical expressions
<RX14>
2) we should be able to get their value from macros
<FromGitter>
<bew> yeah definitely.. we need an isue to track this, can you do it? (or do I do it?)
<RX14>
nah i'm super super tired
<RX14>
been doing plumbing today of all things
<RX14>
spent a lot of the day on my back inside my grandparents kitchen cabinet