ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.29.0 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
alex`` has quit [Ping timeout: 245 seconds]
<FromGitter> <watzon> Another library no one asked for :) https://github.com/watzon/cor
<FromGitter> <watzon> Lol
<FromGitter> <Blacksmoke16> :p
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d15668f189e7b4ff020147a]
<FromGitter> <Blacksmoke16> 😢
<FromGitter> <Blacksmoke16> :P
<FromGitter> <watzon> Lol oh youi
<FromGitter> <watzon> They're coming
<FromGitter> <Blacksmoke16> i hope so :P
<FromGitter> <Blacksmoke16> dont let @girng see you xD
early` has joined #crystal-lang
early has quit [Ping timeout: 246 seconds]
<FromGitter> <Blacksmoke16> @dscottboggs_gitlab https://crystal-lang.org/api/master/toplevel.html#ARGF
<FromGitter> <Blacksmoke16> i realized i can just use this, which handles ARGV/STDIN internally
gangstacat has joined #crystal-lang
<FromGitter> <Blacksmoke16> but im confused
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d156b10189e7b4ff0203dfa]
<FromGitter> <Blacksmoke16> ```--- ⏎ name: Jim ⏎ name: Bob ⏎ {"name" => "Bob"}``` [https://gitter.im/crystal-lang/crystal?at=5d156b1aa611a04ff18d2110]
<FromGitter> <Blacksmoke16> where im giving it two files, one with `---\name: Jim` the other with `\nname: Bob`
<FromGitter> <Blacksmoke16> yet it seems it doesnt parse the yaml like they have both names?
<FromGitter> <Blacksmoke16> oh
<FromGitter> <Blacksmoke16> the 2nd one overrides the first key, :facepalm:
<FromGitter> <Blacksmoke16> thanks for being my duck
<FromGitter> <bajro17> is there any book about crystal except this from Ivo Balbaert or video tutorial on udemy or any other website for video tutorials
<FromGitter> <Blacksmoke16> https://crystal-lang.org/reference/ id read through this if you havent
<FromGitter> <Blacksmoke16> also the API docs
duane has quit [Ping timeout: 272 seconds]
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
duane has joined #crystal-lang
duane has quit [Ping timeout: 258 seconds]
duane has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
duane has quit [Ping timeout: 272 seconds]
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
olbat[m] has quit [Remote host closed the connection]
watzon[m] has quit [Write error: Connection reset by peer]
olbat[m] has joined #crystal-lang
devil_tux has quit [Ping timeout: 272 seconds]
<FromGitter> <girng> hi
<FromGitter> <girng> @Blacksmoke16 :D
<FromGitter> <j8r> How I can create an empty NamedTupleLiteral?
<FromGitter> <cfsamson> Ok, so guys. I'll try again here since it's a new day, but have anyone tried to cross-compile the "hello world" example from the Wiki: https://github.com/crystal-lang/crystal/wiki/Porting-to-Windows on version 0.29? You don't need Windows to try this out since I get a compilation error when cross compiling from ubuntu passing in `crystal build --cross-compile --target x86_64-pc-windows-msvc hello_world.cr`
<FromGitter> ... complaining that `Fiber`is undefined. I have a pretty good feeling that this is caused by some changes made the last 3-4 months but would love if someone could confirm that they get the same error so it's not only me.
<FromGitter> <bew> RX14 would be able to answer I think
<FromGitter> <cfsamson> @RX14 Do you get this working on 0.29? I have gathered some more information about this but just want to rule out that there is an error on my part before spending a lot of time chasing down the wrong rabbit hole (which is very possible but I get this both using the prebuilt binary and when compiling from source) - seems to be mostly related to changes made the last 2-4 months.
<FromGitter> <j8r> @Blacksmoke16 maybe you have an idea of how to create an empty NamedTupleLiteral?
<FromGitter> <watzon> @j8r I'm not sure you can. Why would you wan't to?
<FromGitter> <vladfaust> @watzon https://github.com/watzon/cor/blob/419f3cded326d446a646fc2522ab98c9efee688a/src/cor/cor.cr#L64 how about converting colors to constants or enums? FYI, enums can have custom values like that: ⏎ ⏎ ```enum Color : UInt32 ⏎ Red = 0xff0000 ⏎ Green = 0x00ff00 ⏎ Blue = 0x0000ff ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5d15d7532be6a2404ddbc73f]
<FromGitter> <vladfaust> It's overall a good idea to also allow working with hexes not as Strings but as Numbers
<FromGitter> <vladfaust> Because if using Crystal for game development and your Cor shard, it must be fast
<FromGitter> <j8r> How to force to be a macro in this example, instead of being a class method: https://carc.in/#/r/75lk
devil_tux has joined #crystal-lang
alex`` has joined #crystal-lang
_whitelogger has joined #crystal-lang
<FromGitter> <j8r> I've found a work around, iterate over the namedtuple/hash
<FromGitter> <bew> @j8r well you're passing 2 args to a macro which takes only one..
<FromGitter> <j8r> ok take this https://carc.in/#/r/75lt
<FromGitter> <j8r> anyway not a problem
<FromGitter> <j8r> I've found a workaround somehow
<FromGitter> <bew> @j8r then you need to change the initial macro call to `A.mac(a: 1)` instead of `A.mac({a: 1})` and it works.... But you get an infinite loop ^^
<FromGitter> <j8r> 👍
<FromGitter> <j8r> For creating a NamedTupleLiteral,I 've created a HashLiteral then I've looped inside it to transform it.
<FromGitter> <bew> Looks weird.. ^^
devil_tux has quit [Ping timeout: 268 seconds]
<FromGitter> <girng> NamedtupleLiteral?
<FromGitter> <girng> Is this a new class/type? i never heard of it
<FromGitter> <bew> It's the type NamedTuple in macros
<FromGitter> <girng> ic
<FromGitter> <girng> what is double @@
<FromGitter> <girng> never seen that in crystal code
<FromGitter> <dscottboggs_gitlab> > thanks for being my duck
<FromGitter> <dscottboggs_gitlab> :D
<FromGitter> <dscottboggs_gitlab> @girng double `@` is a class-instance variable. Like ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d15f812a611a04ff1923ba7]
<FromGitter> <girng> shorthand for `class_property`?
<FromGitter> <dscottboggs_gitlab> no, `class_property` is shorthand for that
<FromGitter> <girng> O_O
<FromGitter> <dscottboggs_gitlab> class_property is a macro which translates to ... (hang on typing)
<FromGitter> <girng> ohhh i've seen @@property = before
<FromGitter> <girng> now i remember
<FromGitter> <girng> i guess `@@functions : String?` threw me off
<FromGitter> <girng> It's going to be a class-instance variable function
<FromGitter> <girng> That is expecting a strict return type of a String | Nil
<FromGitter> <dscottboggs_gitlab> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d15f89c4db9b92ce36112dd]
<FromGitter> <girng> Correct?
<FromGitter> <dscottboggs_gitlab> yes ` : String?` is a type restriction for that variable which says that it is either a `String` or `nil`
<FromGitter> <girng> nice
<FromGitter> <girng> that felt good :p
<FromGitter> <girng> i wias first looking at it and was like wtf
<FromGitter> <girng> maybe brain fart, iuno
laaron- has joined #crystal-lang
<FromGitter> <dscottboggs_gitlab> haha
<FromGitter> <dscottboggs_gitlab> @cfsamson the reason you can't compile the hello world is that every crystal program (even a hello-world) comes with an event look and some other extras for the GC and whatnot
laaron has quit [Ping timeout: 260 seconds]
<FromGitter> <girng> ROFL
<FromGitter> <girng> That's so me whe nlooking back at my code '
<FromGitter> <dscottboggs_gitlab> > Yes, that might be. This line might also be an issue ⏎ > ``` ⏎ > {% unless flag?(:win32) %} ⏎ > @[Link("pthread")] ⏎ > {% end %} ... [https://gitter.im/crystal-lang/crystal?at=5d15fb104db9b92ce3612861]
<FromGitter> <dscottboggs_gitlab> @cfsamson ^^
<FromGitter> <dscottboggs_gitlab> @girng lol that's great
<FromGitter> <girng> :D
<FromGitter> <girng> what's a usecase for a spaceship operator
<FromGitter> <dscottboggs_gitlab> I'm sorry?
<FromGitter> <girng> <=>
<FromGitter> <girng> that operator
<FromGitter> <Blacksmoke16> its how `>`, `<`, and `==` is implemented
<FromGitter> <dscottboggs_gitlab> if you define `<=>` on a type, you can then call `==`, `>`, etc on it
<FromGitter> <Blacksmoke16> @j8r not that comes to mind
<FromGitter> <Blacksmoke16> see https://crystal-lang.org/api/master/Comparable.html @girng
duane has joined #crystal-lang
<FromGitter> <dscottboggs_gitlab> I ran @cfsamson's command but with `-D gc_none` and received this output: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ I'm assuming the output is a command I need to run on windows to compile the object file into an executable. What is this `cl` command on windows and is there an equivalent command I can run from wine or linux? [https://gitter.im/crystal-lang/crystal?at=5d160afa490abf627a337de8]
<FromGitter> <cfsamson> @dscottboggs_gitlab OK, but did you get the same error when not compiling with `-D gc_none`? You're right, on Windows you link to gc.lib and pcre.lib to make an executable.
<FromGitter> <dscottboggs_gitlab> yes
<FromGitter> <cfsamson> OK, so I guess that's the solution. Will try to link and compile it on windows and see if it works then.
<FromGitter> <cfsamson> That makes sense, but I would have thought that following the Wiki should work...
<FromGitter> <dscottboggs_gitlab> I agree.
<FromGitter> <cfsamson> Thanks for helping out though!
<FromGitter> <dscottboggs_gitlab> looking through `boehm.cr` it looks like they intend it to work under `win32`, so I would suggest opening an issue regarding this
devil_tux has joined #crystal-lang
duane_ has joined #crystal-lang
<FromGitter> <cfsamson> Yeah, it looks like it. I'll spend a little bit of time on this now that I know I was not the only one getting that error.
duane has quit [Ping timeout: 258 seconds]
<FromGitter> <dscottboggs_gitlab> I compiled a version of the compiler with that taken out, like so, and it built the object. I don't have access to a windows box right now so I can't test if it works though, and I think it will lead to other bugs if you try to use fibers on windows
<FromGitter> <dscottboggs_gitlab> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d1610d9da128007c685dff9]
<FromGitter> <dscottboggs_gitlab> the module `Fiber` (in *fiber.cr* `require`s `"thread/linked_list"`, which requires `"thread/mutex"`, which requires "c/pthread" unconditionally. That won't work on windows.
duane_ has quit [Ping timeout: 246 seconds]
duane has joined #crystal-lang
<FromGitter> <cfsamson> Yes, I'm actually working on a branch aiming to improve windows support for fibers, so I haven't worked on the master branch to debug this. However I concluded the same as you that there is a problem with `c/pthread` on windows. If you look in the `src/libc/ x86_64-windows-msvc` that's not that strange and I think the intention is to use "something" else than `pthread` since that is a POSIX threading API that
<FromGitter> ... won't work on windows anyway. ⏎ ⏎ However I struggle to see where they conditionally compile the C api they use. I see there are platform specific bindings in `std/lib_c` folder but I have no idea how the conditional compilation is designed. Do you have any idea?
duane has quit [Ping timeout: 246 seconds]
<FromGitter> <mistergibson> Seems like they will have to devote a significant amount of time / energy to a platform abstraction layer internally.
<FromGitter> <mistergibson> threads are one area, then there is file system, networking, etc
<FromGitter> <bew> @mistergibson we already have that with `Crystal::System::*`, just not for everything yet..
<FromGitter> <bew> Check in `src/crystal/system/`
<FromGitter> <mistergibson> ah ok -- cool
<FromGitter> <mistergibson> In my ruby stuff I created an extensive System object: FSInfo/Networking/CPUinfo/ProcessInfo/MemoryAllocation
<FromGitter> <mistergibson> down to the cpu flags available
<FromGitter> <mistergibson> We will need this in Crystal as well
duane has joined #crystal-lang
devil_tux has quit [Quit: leaving]
<FromGitter> <cfsamson> @dscottboggs_gitlab I made an issue suggesting a change in the Wiki page instead. That's probably better: https://github.com/crystal-lang/crystal/issues/7932
<FromGitter> <mistergibson> rkeene: I'm not so sure Ruby is dead dead. Maybe it is only half-dead. I mean: I use Opal.rb in the browser and it allows me to barely even touch javascript. I use Ruby for my web servers (NOT RAILS) and it does just fine. It is not in vogue anymore per se, but I suspect that languages like Crystal will bring it back in unusual ways.
<FromGitter> <mistergibson> Crystal will be the C++ for Ruby folks I suspect
<FromGitter> <mistergibson> I love it because it represents the features of C++ w/o the brain damage
<FromGitter> <mistergibson> As for Ruby : I have not found a more elegant language that steals the best features from Smalltalk, LISP, Perl, etc in one place.
<rkeene> POSIX pthreads and Win32 threading aren't so far apart: https://github.com/rkeene/webdraw/blob/master/win32-pthread-emul.h
<FromGitter> <mistergibson> Crystal represents to me the natural evolution of Ruby --> compiled OOP
<rkeene> misteribson, I mean, I use tcl.js in the browser and don't have to use JavaScript either -- people still say Tcl is dead ( https://lobste.rs/s/ziz7xp/tcl_backed_javascript_repl_running_on#c_nzc0uf )
<FromGitter> <mistergibson> Ah the venerable Tcl - yes
<rkeene> Yep, Ruby and Tcl, together :-)
<FromGitter> <mistergibson> I think Ruby is in regrouping mode with the projects I've mentioned
<rkeene> Tcl has all those things and more
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
<FromGitter> <AmberSaber> Many programming languages ​​have been born based on the llvm platform, and llvm is like a programming language pipeline. Perhaps such a tool will appear some time later. You just need to say some features of the programming language you want to design. Then you don't have to do anything, don't think about anything, the computer sounds a few times, then a programming language named with your name is
<FromGitter> ... born.
duane has quit [Ping timeout: 272 seconds]
laaron has joined #crystal-lang
laaron- has quit [Remote host closed the connection]
_whitelogger has joined #crystal-lang
alex`` has joined #crystal-lang
<FromGitter> <watzon> @vladfaust that's not a bad idea
greengriminal has joined #crystal-lang
<FromGitter> <wontruefree> is there a library for cidr bases ip addresses?
<FromGitter> <j8r> @wontruefree to do what?
<FromGitter> <girng> why remove the gc
<rkeene> j8r, Here's what the Tcl library for IPs does and it's been pretty handy: https://core.tcl-lang.org/tcllib/doc/trunk/embedded/md/tcllib/files/modules/dns/tcllib_ip.md
<rkeene> Especially what would otherwise be tedious things like subtraction, so you could compute 1.2.3.0/24 -1.2.3.4 to get 1.2.3.0/30 1.2.3.5/32 1.2.3.6/31 1.2.3.8/29 1.2.3.16/28 1.2.3.32/27 1.2.3.64/26 1.2.3.128/25
<FromGitter> <watzon> There's a nice ruby gem for handling IP addresses https://github.com/ipaddress-gem/ipaddress
<FromGitter> <watzon> Shouldn't be too hard to make a crystal shard that's similar
<rkeene> And add subtraction
<FromGitter> <girng> If the GC is disabled in Crystal. Does this mean, each time a class is initialized, we will have add a memory deallocation to its constructor?
<FromGitter> <girng> deconstructor**
<FromGitter> <girng> But wait, how does Crystal know an object is going to die without a GC
<FromGitter> <watzon> Who's talking about removing the GC? The only way to not have a GC would be to do what Rust does.
<FromGitter> <girng> > I compiled a version of the compiler with that taken out
<FromGitter> <wontruefree> I want to detect overlaps of cidr know if an ip is in a cidr range
<FromGitter> <girng> i was just scrolling up and saw why
<FromGitter> <Blacksmoke16> he was trying to get it to compile on windows
<FromGitter> <girng> but why
<FromGitter> <wontruefree> I guess detecting overlaps is not that hard
<FromGitter> <Blacksmoke16> to work on implementing FIbers
<FromGitter> <wontruefree> but I still want to know if an IP is inside a cidr
<FromGitter> <Blacksmoke16> otherwise it just doesnt compile
<FromGitter> <girng> wait, boehm doesn't compile on windows?
<FromGitter> <girng> > I love it because it represents the features of C++ w/o the brain damage ⏎ ⏎ :D
<FromGitter> <watzon> How can I do what ruby does with `Array#pack(" B*")`?
<FromGitter> <watzon> ```["11111111111111111111111100000000"].pack("B*") ⏎ => "\xFF\xFF\xFF\x00"``` [https://gitter.im/crystal-lang/crystal?at=5d1670d1aa095d404cd57348]
<FromGitter> <watzon> There we go
<FromGitter> <watzon> I know I've seen it before, just couldn't remember
<FromGitter> <watzon> Oh how I would love to have `String#pack` and `Array#unpack`
<FromGitter> <watzon> I'm sure `ByteFormat` is right, but I have no idea how to get the same output with it
<FromGitter> <tenebrousedge> you had to ask D:
<FromGitter> <Blacksmoke16> hmm
<yxhuvud> What I'm wondering is why you have the bitfield as a string in the first place
<yxhuvud> You may want to look up BitArray
<FromGitter> <watzon> Not an unfair question haha
<FromGitter> <Blacksmoke16> `"11111111111111111111111100000000".to_i64(2).to_s(16) # => ffffff00`
<FromGitter> <Blacksmoke16> :shrug:
<FromGitter> <watzon> This does give me what I
<FromGitter> <watzon> `"11111111111111111111111100000000".scan(/[10]{8}/).to_a.map(&.[0]).map(&.to_u8(2))`
<FromGitter> <watzon> But eww
<FromGitter> <Blacksmoke16> oh so you want an array of the bytes?
<FromGitter> <watzon> Yeah
<FromGitter> <watzon> Maybe I should've led with that
<FromGitter> <kinxer> I'm reading the documentation for Ruby's Array#pack (https://www.rubydoc.info/stdlib/core/Array:pack), and I don't like it.
<FromGitter> <Blacksmoke16> `"11111111111111111111111100000000".to_i64(2).to_s(16).hexbytes`
<FromGitter> <Blacksmoke16> er
alex`` has quit [Ping timeout: 272 seconds]
<FromGitter> <watzon> Well that works
greengriminal has quit [Quit: This computer has gone to sleep]
<FromGitter> <watzon> @kinxer what don't you like?
<FromGitter> <Blacksmoke16> i wouldn't be surprised if there is a shortcut to that tho
<FromGitter> <watzon> I wouldn't either
<FromGitter> <watzon> There must be
<FromGitter> <kinxer> It's just a weird little domain language for converting string contents between byte representations?
alex`` has joined #crystal-lang
<FromGitter> <kinxer> It's just very arcane.
<FromGitter> <girng> looks confusing af
<FromGitter> <kinxer> Yeah, that's basically what I was trying to say.
<FromGitter> <girng> i'm with you, i don'tl ike it either
<FromGitter> <girng> reminds me of the brain f-word language
<FromGitter> <girng> lol
<FromGitter> <watzon> Brainfuck?
<FromGitter> <watzon> Lol
<FromGitter> <girng> yah hahahaha
<FromGitter> <girng> i've seen codegolf solutions of people using that on stackoverflow
<FromGitter> <girng> like wtf.....
greengriminal has joined #crystal-lang
<FromGitter> <mwlang> Is the "./src" folder built into the shard library hard-coded or is it something easily changed?
<FromGitter> <watzon> You can use whatever folder you want
<FromGitter> <mwlang> oh, and I guess that begs the next question of convention over configuration...is this a strongly followed convention we're discouraged from changing or just happens to be what I see in the roughly 10 or so shard sources I've reviewed to-date?
<FromGitter> <watzon> `./src` is just a convention
<FromGitter> <watzon> If you don't have a good reason to change it I wouldn't
<FromGitter> <Blacksmoke16> id bet 99% of shards use `src`
<FromGitter> <mwlang> well, I'm just so used to "app" and "lib" containing my sources from Ruby projects.
<FromGitter> <Blacksmoke16> :p
<FromGitter> <mwlang> I keep "automatically" expanding "lib" to look for my code.
<FromGitter> <mwlang> old habits die so hard.
<FromGitter> <Blacksmoke16> can still do that after you install shards
<FromGitter> <mwlang> esp. daily ones of 10+ years.
<FromGitter> <watzon> Haha yeah you definitely can't use lib though
<FromGitter> <watzon> That's where other shards get installed so that would fuck everything up
<FromGitter> <mwlang> well, we don't want that.
<FromGitter> <Blacksmoke16> er but, shouldnt commit lib dir so ofc only when first installing it
<FromGitter> <Blacksmoke16> when installing locally*
<FromGitter> <mwlang> not gonna mess with lib folder...was really only thinking to rename the src folder "app" so it's at top of the tree.
<FromGitter> <Blacksmoke16> give it a try
<FromGitter> <mwlang> so weird having my spec folder come *before* my source
<FromGitter> <Blacksmoke16> or just get used to it :P
<FromGitter> <mwlang> you're the master of of "do it or don't do it, it's up to you" 😆
<FromGitter> <mwlang> I'll just keep on trying to break the habit...that 99.995% comment above convinces me since I ain't a betting person -- at least not this bet, anyhow.
<FromGitter> <Blacksmoke16> sounds like a plan
greengriminal has quit [Quit: This computer has gone to sleep]
greengriminal has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
<FromGitter> <mwlang> making good progress on the binance api wrappers. Got that whacky 2D array response wrapped succinctly.
<FromGitter> <girng> lol
<FromGitter> <girng> nice michael :)
alex`` has quit [Quit: WeeChat 2.5]
alex`` has joined #crystal-lang
alex`` has quit [Ping timeout: 268 seconds]
DTZUZO has joined #crystal-lang