ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.21.1 | Fund Crystal's development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
olek_poz has quit [Ping timeout: 260 seconds]
Svenskunganka has quit [Quit: leaving]
Svenskunganka has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 260 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 246 seconds]
Svenskunganka has quit [Quit: leaving]
Svenskunganka has joined #crystal-lang
xmonader has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 240 seconds]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter> <williamokano> Hello guys
bjz has joined #crystal-lang
pawnbox has joined #crystal-lang
<FromGitter> <fridgerator> hello
pawnbox has quit [Ping timeout: 264 seconds]
<FromGitter> <williamokano> Hi, I'm kind confused, just started with crystal and I'm kind of lost
<FromGitter> <williamokano> The require it's always relative path? Or it will start scanning from the root folder? My question is, if I'm inside of a folder 5 levels deep, do I need to require this way? `require ../../../../../some_file.cr` or there's more efficients way to load the files?
<FromGitter> <fridgerator> yes require is relative
<FromGitter> <fridgerator> its a common pattern in crystal (and in ruby) to require everything from the base .cr file
<FromGitter> <williamokano> I'm taking a look at the kemal framework, just noticed that in the "main (kemal.cr)" they do a require with star `require "kemal/*"`. Is it a best practice?
<FromGitter> <fridgerator> yeah its pretty standard
<FromGitter> <williamokano> Sorry, don't know ruby and just started with crystal, just being noob here hahaha (my bad)
<FromGitter> <fridgerator> no worries!
<FromGitter> <williamokano> Noob question, that means that it will load everything down recursively? Or should I use some bash-like syntax? `require "myfolder/**/*"`?
<FromGitter> <fridgerator> `/*` will only require the files in that folder, not recusive
<FromGitter> <fridgerator> you can use `/**` for recursive, or include each folder, like kemal does
<FromGitter> <williamokano> I see, gonna try some stuff. Thanks a lot. Helped a lot :)
<FromGitter> <fridgerator> great, have fun
<FromGitter> <williamokano> thanks m8
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
pawnbox has joined #crystal-lang
<FromGitter> <williamokano> Another silly question, is it possible to use generics only in the method?
pawnbox has quit [Ping timeout: 240 seconds]
VectorGraphics has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 256 seconds]
soveran has joined #crystal-lang
<FromGitter> <fridgerator> You mean without special
<FromGitter> <williamokano> No, for example, in C# I can use generic only in the method, so I don't have to specify it on the class, but in the method. Something like that
<FromGitter> <williamokano> ```res = my_obj.some_method<AnotherKindOfObject> param1, param2```
<FromGitter> <fridgerator> Ah, that I'm not sure
<FromGitter> <fridgerator> I would have to play around to see what's possible
soveran has quit [Ping timeout: 240 seconds]
<FromGitter> <williamokano> I'm probably wrong, but as I saw in the crystal docs, I should do ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Probably I'm getting confused since my thinking still tied to C#. [https://gitter.im/crystal-lang/crystal?at=58c216ef1465c46a560f9f8a]
<FromGitter> <williamokano> I'm trying to write a generic method to send requests where I model the requests into objects (like guzzle http for php if you are familiar), but when I execute the method send (which is generic) I have to translate it to an specific class. So I was thinking in using generics to "Type" the return method, but I'm kind of stucked. Here's my example. PS.: not my best code hahaha h
<FromGitter> ... ttps://github.com/williamokano/pagarme-crystal/blob/master/src/pagarme/client.cr
<FromGitter> <williamokano> @fridgerator Gonna sleep now. Thanks a lot for the help and the support. :) Gonna try this tomorrow, I'm too tired to keep trying right now hahaha. Have a good night mate.
<FromGitter> <fridgerator> alright dude, glad I could help, you have a good night as well
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 258 seconds]
bjz has joined #crystal-lang
pawnbox has joined #crystal-lang
jadams has joined #crystal-lang
pawnbox has quit [Ping timeout: 240 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 260 seconds]
splitty_ has quit [Read error: Connection reset by peer]
Svenskunganka has quit [Quit: leaving]
Svenskunganka has joined #crystal-lang
pawnbox has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 260 seconds]
splitty_ has joined #crystal-lang
_whitelogger has joined #crystal-lang
pawnbox has quit [Read error: Connection reset by peer]
pawnbox has joined #crystal-lang
VectorGraphics has quit [Quit: Leaving]
soveran has joined #crystal-lang
olek_poz has joined #crystal-lang
soveran has quit [Ping timeout: 260 seconds]
Raimondi has quit [Read error: Connection reset by peer]
Raimondii has joined #crystal-lang
Raimondii is now known as Raimondi
xmonader has quit [Ping timeout: 256 seconds]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
pawnbox has quit [Read error: Connection reset by peer]
pawnbox has joined #crystal-lang
bmcginty has quit [Ping timeout: 240 seconds]
bmcginty has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
<shelvacu> Is there any way to have thread-local variables in crystal right now?
Raimondi has quit [Remote host closed the connection]
Raimondi has joined #crystal-lang
bmcginty has quit [Ping timeout: 264 seconds]
bmcginty has joined #crystal-lang
synstack has joined #crystal-lang
olek_poz has quit [Ping timeout: 260 seconds]
mark_66 has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 256 seconds]
Philpax has joined #crystal-lang
soveran has left #crystal-lang [#crystal-lang]
pawnbox has joined #crystal-lang
olek_poz has joined #crystal-lang
bjz_ has joined #crystal-lang
bjz has quit [Ping timeout: 260 seconds]
Ven has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
Raimondii has joined #crystal-lang
pawnbox has quit [Ping timeout: 260 seconds]
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
Ven has quit [Ping timeout: 260 seconds]
Ven has joined #crystal-lang
gloscombe has joined #crystal-lang
Ven has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox_ has joined #crystal-lang
pawnbox has quit [Ping timeout: 260 seconds]
bjz_ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
xmonader has joined #crystal-lang
bjz has joined #crystal-lang
Ven has quit [Ping timeout: 264 seconds]
mjago has joined #crystal-lang
pawnbox_ has quit [Remote host closed the connection]
Ven has joined #crystal-lang
pawnbox has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
sija has joined #crystal-lang
xmonader has quit [Ping timeout: 260 seconds]
pawnbox has quit [Remote host closed the connection]
xmonader has joined #crystal-lang
Ven has quit [Ping timeout: 256 seconds]
Ven has joined #crystal-lang
sz0 has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
Philpax has quit [Ping timeout: 260 seconds]
xmonader has quit [Ping timeout: 260 seconds]
Ven has quit [Ping timeout: 240 seconds]
Ven has joined #crystal-lang
<FromGitter> <Skyne98> Hello everyone!
<FromGitter> <Skyne98> I have a question here, that, mayby, was raised here a lot of times
<FromGitter> <Skyne98> Is it possible to use compiled Crystal code for OS / Kernel creation?
<FromGitter> <Skyne98> As, for example, it is possible with Rust quite easily
<FromGitter> <Skyne98> And, the second question
<FromGitter> <Skyne98> How does Crystal handle memory problems?
<FromGitter> <Skyne98> Because Rust, for instance, is famous for it's way of coping with memory issues
<FromGitter> <Skyne98> That makes this language too ugly and complicated
<FromGitter> <Skyne98> Whilst Crystal looks very clean and neat
<FromGitter> <Skyne98> Does it mean that Crystal has any drawbacks comparing to Rust?
xmonader has joined #crystal-lang
sz0 has quit [Quit: Connection closed for inactivity]
olek_poz has quit [Ping timeout: 260 seconds]
<jokke> Skyne98: well, crystal has a GC
<jokke> whereas rust does not
<jokke> makes the runtime bigger, but also more pleasant to code, since you don't have to worry about it
<FromGitter> <Skyne98> ok, thanks for your answer :)
<FromGitter> <Skyne98> but what abount native code?
<FromGitter> <Skyne98> can it be loaded on the first stages of setting up a kernel?
<FromGitter> <Skyne98> because Rust, for example, has "core" libraries, that can be easily loaded via assembler
<jokke> Skyne98: there's already a 32bit x86 kernel written in crystal
<jokke> do you mean C with native code?
<jokke> it's very easy to include C libraries in crystal
<jokke> easier than i've seen in any other language so far
<FromGitter> <Skyne98> and all this stuff can be easily done on the kernel level?
<FromGitter> <Skyne98> I could find
<FromGitter> <Skyne98> i would be nice of you to give me a link to this kernel project
<FromGitter> <Skyne98> nice
<FromGitter> <Skyne98> couldn't
<jokke> i'll try
<jokke> there you go
<RX14> it's actually quite hard to use crystal to write an OS right now, but just about possible
<FromGitter> <Skyne98> thanks!
<FromGitter> <Skyne98> this language is like a beam of light for me
<RX14> there's a lot more places where the crystal compiler interfaces with the stdlib than in rust
<RX14> so there's a lot more boilerplate needeed in your stdlib to start writing code
<RX14> hopefully we'll address that before 1.0
<jokke> RX14: any plans in writing the GC in crystal?
<jokke> *of
<FromGitter> <sdogruyol> @jokke eventually
<RX14> well maybe
<RX14> but it doesn't really help for writing an OS either way
<FromGitter> <Skyne98> hmm, if it does interface it, how is it possible to avoid it?
<FromGitter> <Skyne98> make own implementation of stdlib?
<RX14> you essentually have to not have a GC
<jokke> RX14: yeah
<RX14> yes, you can turn off the stdlib
<RX14> and you write your own essentially
<RX14> using --prelude=empty compiler options
<jokke> that was my plan too
<RX14> using --prelude=empty compiler option
<jokke> to write a very basic stdlib
<jokke> for uC programming
<RX14> it would be really nice to have that jokke
<jokke> yeah.. i wish i had more time
<FromGitter> <Skyne98> hmm
<RX14> alternate stdlib implementations would be great for trimming down that compiler<>stdlib API
<FromGitter> <Skyne98> so, guys, to summarize things
<FromGitter> <Skyne98> what do I have to do to achieve what I want?
<FromGitter> <Skyne98> briefly
<RX14> there is no brief
<jokke> :D
<FromGitter> <Skyne98> yep, I see )
<RX14> for example NuummiteOS
<RX14> that took a good week of me and splitty, the lead dev on IRC to get stuff working
<RX14> it's *hard*
<RX14> it's unbeaten path
<FromGitter> <Skyne98> I know :)
<FromGitter> <Skyne98> isn't it great?
<FromGitter> <Skyne98> and, that took you a week, you have done the essential work, now others can use you achievements as foundation to go even further
<FromGitter> <Skyne98> can we keep in touch in some way, guys?
<jokke> we're always here
<jokke> Skyne98
<jokke> always watching...
<jokke> :D
<FromGitter> <Skyne98> "always" like always, or more like twice a day?
<jokke> i'm here 24/7
<FromGitter> <Skyne98> :D
<jokke> if you mention me i'll get back to you as soon as i'm online
<FromGitter> <Skyne98> yep, thanks
<jokke> and i'm online _alot_ :D
<jokke> <- has no life
<FromGitter> <Skyne98> ahahha :D
<FromGitter> <Skyne98> you know
<FromGitter> <Skyne98> building kernels is cooler
<FromGitter> <Skyne98> than life
<jokke> :D
<FromGitter> <Skyne98> and
<FromGitter> <Skyne98> I am quite new to linux
<FromGitter> <Skyne98> t*
<FromGitter> <Skyne98> can you suggest me some good virual machines?
<jokke> on linux?
<FromGitter> <Skyne98> yep
<FromGitter> <Skyne98> are there any?
<jokke> qemu
<jokke> i guess
<RX14> qemu is what most people use for building OSes
<jokke> yup
<jokke> also has good virtualization for many uC architectures
<FromGitter> <Skyne98> and, guys
<FromGitter> <Skyne98> nice
<FromGitter> <Skyne98> i know it took like, a whole week to wrap your heads around this
<FromGitter> <Skyne98> and build this
<jokke> not me
<FromGitter> <Skyne98> but, how would toy rate the complexity of this code?
<FromGitter> <Skyne98> for me to dive into it
<FromGitter> <Skyne98> ok then, RX14
<FromGitter> <Skyne98> :D
<jokke> Skyne98: any experience with llvm?
<FromGitter> <Skyne98> nope, but i learn fast
<FromGitter> <Skyne98> if i have somewhere to start from, sure
<FromGitter> <Skyne98> so, what about it?
raz has joined #crystal-lang
<raz> just found crystal
<raz> now i can't wait for crystal-on-rails
mark_66 has quit [Remote host closed the connection]
<FromGitter> <fridgerator> @raz are you familiar with sinatra? there is kemal, which works great
<raz> wow thx for the pointer. gonna have a look!
<jokke> raz: there's also crouter :P
<jokke> some self advertisement :P
ducklobster has joined #crystal-lang
<raz> definitely also gonna have a look at that
<jokke> :)
<jokke> raz: have fun with crystal and spread the word! also don't be afraid to contribute. the community is exceptionally nice
<ducklobster> Hi all, new to Crystal and messing around with some scripts
<ducklobster> Wondering if what I am doing is the "crystal" way to do things
<jokke> hi ducklobster! welcome
<ducklobster> I know that the String#each_lines method returns an Iterator
<ducklobster> which is lazily done
<ducklobster> It looks like #map doesn't work on that?
<ducklobster> Is it better to do my_string.each_line.to_a.map
<ducklobster> or my_string.lines.map
<jokke> the latter
<jokke> but
<jokke> each_line.map should work as well
<ducklobster> it seems like the second, but I'm wondering if each_line has an option to return an Enumerable instead of an Iterator
<ducklobster> each_line.map doesn't seem to work for me :(
<jokke> ah
<jokke> i see
<ducklobster> not sure what the expected behavior should be, I can throw up a gist with real code if that helps?
<ducklobster> or i can just go on using my_string.lines.map :)
<jokke> i'd have to dig into the stdlib a bit as well
<jokke> hm map _should_ work
<jokke> sure you can, but that will load all lines in to memory
<jokke> *into
<jokke> it works
<jokke> puts "foo\nbar\nbaz\n".each_line.map { |line| "#{line} test" }.to_a
<jokke> ["foo test", "bar test", "baz test"]
<jokke> (this will of course also load everything into memory
<jokke> but that's because of the .to_a
<jokke> you could chain it with select or find though which would be more efficient memory-wise than lines.map
<jokke> *than with
Ven has quit [Ping timeout: 246 seconds]
Ven has joined #crystal-lang
<FromGitter> <Skyne98> jokke, don't you think that any language like this should be modular, though have special "core" modules that don't depend on std?
ducklobster has quit [Ping timeout: 260 seconds]
<jokke> well, yes. but give crystal some time :) it's still pre 1.0 and very young
<FromGitter> <Skyne98> there is just no lightweight and beautiful enough low-level language :)
<FromGitter> <Skyne98> and crystal, I think, has quite a big potential
<FromGitter> <sdogruyol> @Skyne98 indeed
<jokke> yes
<jokke> i'd just love to be able to write crystal for uCs
<FromGitter> <Skyne98> but it look like it doesn't really position itself like c-alternative
<FromGitter> <Skyne98> it looks like it wants to be more high-end
<Papierkorb> Skyne98, that's why it's not
<jokke> probably because that sounds intimidating :D
<Papierkorb> s/why/because/
<FromGitter> <Skyne98> yes, i totally understand, that Crystal wants to be quite high-level and satisfying to people developing high-end software
<FromGitter> <Skyne98> but why there is still no simple, yet beautiful lightweight low-level languages?
<Papierkorb> What are you missing?
<Papierkorb> C doesn't imply low-level
<FromGitter> <Skyne98> it mostly does
<FromGitter> <Skyne98> and it's hard to argue about that
<Papierkorb> Again, what are you missing?
<Papierkorb> There have even been written operating system kernels in Crystal. I wrote one myself.
<Papierkorb> Doesn't get much more low level than that on standard x86 hardware
<FromGitter> <Skyne98> I am not trying to be smart here, sorry if I did :) I am just totally new to low-level development and my background is totally C#-ish
<FromGitter> <Skyne98> So, mayby, I already have all the tools needed to achieve my goals
<FromGitter> <Skyne98> But I don't really know where to start
Ven has quit [Ping timeout: 260 seconds]
<FromGitter> <Skyne98> Now I am just looking for some kind of C#-ish C :D
<Papierkorb> C++
Ven has joined #crystal-lang
<FromGitter> <Skyne98> C++ lacks simplicity and beauty of C#
<FromGitter> <Skyne98> however, they are both very old and "heavy" languages
<FromGitter> <Skyne98> despite C# becoming open-source and cross-platform lately
<FromGitter> <Skyne98> though, is the idea of making something, that C originally wanted to be (assembler being more easy to read and write), but with modern technologies, ideas and practices really bad?
<FromGitter> <Skyne98> just trying to hear your constructive thoughts :)
<Papierkorb> Rust.
<FromGitter> <Skyne98> Rust looks and feels terrible
<FromGitter> <Skyne98> but rust is the best example of the goal I am talking about
<Papierkorb> And I need a quotation on it being readable assembler. C is a system programming language
<FromGitter> <Skyne98> as far as I know, C is not limited to doing something exact, because with right compiler it would be able to leverage most of the x86 assembly potential
<Papierkorb> As with any other ahead of time or just in time compiler
<Papierkorb> That's their job
<FromGitter> <Skyne98> sure
<FromGitter> <Skyne98> and, yes, there are lots of languages out there, that have full assembly potential, but all of them share one big problem, as I can understand
<FromGitter> <Skyne98> it is platform dependencies
<Papierkorb> Really the only languages having those issues are those from Microsoft
<Papierkorb> And possibly Objective-C for apple stuff
<FromGitter> <Skyne98> I think you are right
<FromGitter> <Skyne98> It is hard to argue about that :)
<FromGitter> <Skyne98> Do you have a minute?
<FromGitter> <Skyne98> However, I would be very pleased, if you could help me wrap my head around the concept of Crystal, for example
sija has quit [Quit: Connection closed for inactivity]
<Papierkorb> Even with MS finally opensourcing parts (only parts ...) of .Net, it's not viable and still shrieks of microsoft three E. We had Mono for years, and it works fine with many .Net only programs, but do many people use it? Not really. Some corporations do, sure, but it's not as a success as, say, Java was for that
<Papierkorb> Sure, ask away
<FromGitter> <Skyne98> Does every "native binary" can be called without actual OS behind it's back?
<FromGitter> <Skyne98> And what about Crystal?
<Papierkorb> No, normal binaries expect a specific user-space, which is provided by operating systems. As the API layer between operating system kernel and the user-space are different, you can usually not run binaries everywhere.
<Papierkorb> But that doesn't apply to source code. You can compile the same code on Windows and Linux (and mac and ...) and then run the program just fine
<FromGitter> <Skyne98> Sure, these are basic concepts, but what about going below os-level?
<FromGitter> <Skyne98> What kind of compiled binaries can be used there?
<Papierkorb> You mean the kernel?
<FromGitter> <Skyne98> Yep
<FromGitter> <Skyne98> The are limited only by the set of CPU instructions, as I understand
<Papierkorb> When any system boots (x86, ARM, ...), a program runs and sets everything up (BIOS, UEFI, "the firmware", ...), that program then hands control over to the next program, a bootloader, whose important task is then to find the kernel to load and starts it. Every platform works akin to this, although the firmware/bootloader steps may be really "small" or barely configurable (Like with micro-controllers)
<Papierkorb> Of course, those programs need to utilize the processors instruction set.
<Papierkorb> An kernel for ARM won't boot on x86 and vice-versa. It's like you trying to speak italian with a chinese guy.
<FromGitter> <Skyne98> Sure, all of THESE concepts are still quite familiar to me
<Papierkorb> What's your question then?
<Papierkorb> The instruction set isn't the point really, a kernel couldn't care less
<FromGitter> <Skyne98> How could it not care, if you write kernel in, essentially, assembler, that consists of these instructions?
<Papierkorb> You don't write kernels in assembler
<Papierkorb> Usually that is
<FromGitter> <Skyne98> Yep, you have a point, you wouldn't
<Papierkorb> There may be components written in assembler
Ven has quit [Ping timeout: 258 seconds]
<Papierkorb> Windows, Linux and mac os kernels all use C to the best of my knowledge.
<Papierkorb> But that's not to say that C is required. C++ can be used, Rust, even Crystal. Doesn't matter much.
<Papierkorb> You can even use PureBASIC (yes, a basic dialect) to write kernels
<FromGitter> <Skyne98> Yes, and there comes the part, that interests me the more
<Papierkorb> And now, I'm away. dinner time.
<FromGitter> <Skyne98> How can you utilize a language, that has some OS dependent features?
<FromGitter> <Skyne98> Oh, have a nice dinner :D
<FromGitter> <Skyne98> See you soon?
Ven has joined #crystal-lang
<RX14> you remove the OS dependant features to write the kernel
<RX14> C and Rust have os-dependant features in their stdlibs
<RX14> Crystal does too
<RX14> in all of them you remove the stdlib and use the languages primatives to manipulate the hardware by scratch
<RX14> all of the above have inline assembler functionality as part of this
<RX14> it's just in C and Rust the compiler<>stdlib API is very clearly defined
<RX14> in Crystal it's not
<FromGitter> <Skyne98> hm, thanks for clarifications
<FromGitter> <Skyne98> is it planned to define this "part" of crystal into something separate?
Ven has quit [Ping timeout: 258 seconds]
xmonader has quit [Ping timeout: 240 seconds]
Ven has joined #crystal-lang
bmcginty has quit [Ping timeout: 268 seconds]
bmcginty has joined #crystal-lang
<RX14> well I hope so
<RX14> I should really make an issue about it...
<FromGitter> <Skyne98> it's a great idea :)
mjago has quit [Remote host closed the connection]
Ven has quit [Ping timeout: 240 seconds]
Ven has joined #crystal-lang
xmonader has joined #crystal-lang
<FromGitter> <paulcsmith> Hi everyone :) I'm doing some work on my little side project https://github.com/luckyframework/web
<FromGitter> <paulcsmith> Stuck on doing route inference. Here's roughly what I'm trying to do. Any ideas how it could be done? https://github.com/luckyframework/web
<FromGitter> <paulcsmith> Also tried using a constant that is an array of booleans, but the `finished` macro doesn't appear to have access to constants :S Maybe I'm just using it incorrectly https://play.crystal-lang.org/#/r/1pgc
<FromGitter> <luislavena> @paulcsmith here is an example of `finished` accessing constants: https://github.com/crystal-lang/crystal/pull/3612
<FromGitter> <paulcsmith> Thanks @luislavena I still can't get it too work, but I'll wrestle with it a bit more :)
<FromGitter> <luislavena> well, macros are a bit more dumb. Not sure you can evaluate a constant value within the macro
<FromGitter> <paulcsmith> Took some messing around, but this works: https://play.crystal-lang.org/#/r/1pgd
<FromGitter> <paulcsmith> The trick was moving the `macro finished` *inside* of `macro inherited`
<FromGitter> <paulcsmith> Also had to change the constant to an array because it wouldn't let me just set it to `false` and then change it to `true`
<FromGitter> <luislavena> hmm, `macro finished` is run after all the macros have been run, nested macros is a neat trick, but not 100% sure is the best approach.
<FromGitter> <luislavena> but I can't say I have an answer, macros is a part I haven't used extensively yet so seems you know more than me :D
<FromGitter> <paulcsmith> Haha I don't know much either. Mostly messing around until it works :P
Ven has quit [Ping timeout: 240 seconds]
Ven has joined #crystal-lang
Ven has quit [Ping timeout: 264 seconds]
Ven has joined #crystal-lang
<FromGitter> <bcardiff> @luislavena the `macro finished` has the drawback IMO that it's name refers to a compilation time and is not a semantic name like inherited / included so necessarily will force push the user into some low-level stuff. I think I wrote something about that motivated on the nested macros scenario ... but guess what.. I can't find it :-(
olek_poz has joined #crystal-lang
Ven has quit [Ping timeout: 240 seconds]
Ven has joined #crystal-lang
xmonader has quit [Ping timeout: 258 seconds]
<FromGitter> <schoening> Ive been looking at the C binding examples. So I gotta build all the return value structs in crystal if I want to return them, right?
<Papierkorb> schoening, that is correct
<Papierkorb> schoening, also, make sure to mark structures as packed if they're also packed in C
<Papierkorb> in the best case your program crashes otherwise, or really funky things happen which are nigh impossible to debug later on
<FromGitter> <schoening> @Papierkorb, thanks for the tips. I will do that as soon as I learn what you are talking about :D
<FromGitter> <schoening> I have not used C much. All I currently want is to return the pixels of a Xlib image. But that struct contains a struct, and a bunch of function pointers.. So I think it's better I create a mini library in C that only returns a struct / array containing the pixels.
<Papierkorb> schoening, C structures can be packed or not packed. Not packed, which is the default (both in C and in Crystal lib structs), means that the compiler may add padding at certain positions for speed purposes. A packed structure never adds padding. So if you mix those up, say the C struct is not packed but your crystal struct is packed, you may read/write garbage in Crystal for /some/ fields. Really confusing if setting things works "
<Papierkorb> sometimes". Especially bad as that can also slip through testing if you don't test the usage of every field.
<FromGitter> <schoening> Ah! Yeah that is important
<Papierkorb> schoening, consider this C struct: `struct { uint8_t val; }` - This is not packed, and the compiler will most likely add padding to it, inflating it to 4Bytes in size, instead of 1Byte as you might expect. If you told the C compiler that this struct shall be packed, it will actually be only 1 Byte in size
bjz has joined #crystal-lang
<FromGitter> <schoening> I'll keep this in mind. Thanks man.
<Papierkorb> schoening, if you want to see it yourself, you can use this: `struct { uint8_t a; uint32_t b; }`. The compiler should add padding after `a` to align `b` on a 4Byte boundary. If you forget to set this to packed (or not packed), you'll read garbage in either Crystal or C.
<Papierkorb> From experience, the last thing you want at 3am when you're working on "that last feature of the day" to get pissed cause suddenly the structure goes haywire ;)
<FromGitter> <schoening> Haha! Yes.. it's not a good feeling. I don't sleep when when the last work I did ended with "fuck it, I'll fix it tomorrow"
<RX14> ah nice
<RX14> a segfault
<crystal-gh> [crystal] bcardiff pushed 3 new commits to master: https://git.io/vyr1h
<crystal-gh> crystal/master 3e1abe3 Brian J. Cardiff: Merge pull request #4076 from karlseguin/feature/empty_named_tuple_to_h...
<crystal-gh> crystal/master fe13cbc Brian J. Cardiff: Add spec to to_h of empty tuples
<crystal-gh> crystal/master abe4f80 Karl Seguin: Calling an NamedTuple#to_h now generates a meaningful error message
<RX14> well uhh
<crystal-gh> [crystal] bcardiff pushed 1 new commit to master: https://git.io/vyrMg
<crystal-gh> crystal/master 8a437e6 Sijawusz Pur Rahnama: Add Crystal::LLVM_VERSION to docs (#4123)
<RX14> raising an exception in my project is dumping random memory top stdout
<Papierkorb> SHA1 producing garbage in release mode on LLVM3.5 still takes the cake for me
<RX14> that was more a LLVM bug though
<RX14> than a crystal bug
<RX14> but still
<Papierkorb> Yes, still, it's not something you'd expect from a project like LLVM
<RX14> well i'd suggest you lower your expectations then
<RX14> if clang doesn't codegen it it's probably going to have bugs
<RX14> so essentially CallStack#decode_backtrace is breaking
<RX14> *sigh*
<RX14> lets go use a crystal compiler built with a decent LLVM release
<RX14> i'm mostly building crane so I can get away from using the *terrible* precompiled releases crenv uses
<FromGitter> <sdogruyol> why terrible?
<RX14> because they use llvm 3.5
<FromGitter> <sdogruyol> woot?
<RX14> and are half-statically compiled
<FromGitter> <sdogruyol> that's no good
<RX14> and just weird
<RX14> the whole crystal binary release process on linux is shit
<FromGitter> <sdogruyol> haven't tried that in a while but yeah even on Debian it was not as smooth as OS X
<RX14> well
<Papierkorb> I just use the archlinux packet
<RX14> i need old compiler versions often#
<RX14> so i need crenv
<RX14> or some version manager
<RX14> using a built compiler didn't fix it
<RX14> so looks like a problem with the DWARF parser or aomething
<RX14> i hate not being able to trust backtraces
<RX14> I added comment lines to change the line numbers and nothing changed in the backtrace
<RX14> it's just annoying
Ven has quit [Ping timeout: 260 seconds]
Ven has joined #crystal-lang
<FromGitter> <luislavena> I'm trying to get the omnibus recipes working locally so I can send a pull request with updated LLVM and other details (like `-fPIC`)
<FromGitter> <luislavena> @RX14 ^^
<RX14> yeah well
<RX14> i'd just rm -Rf omnibus and start again
<FromGitter> <luislavena> the thing is package for debian, I don't know how to do it, honestly
<RX14> how to update llvm?
<RX14> use the LLVM apt repos
<RX14> and install llvm-3.9
<FromGitter> <luislavena> I mean for the embedded one, I have everything compiled locally, but that doesn't solve other's problems
<RX14> oh...
<RX14> well i would have thought they used the LLVM from the repos anyway
<RX14> i'm not sure
<FromGitter> <luislavena> it confuses me the llvm and llvm_bin recipes
<FromGitter> <luislavena> will invest some time this weekend and try to figure it out.
<FromGitter> <sdogruyol> i wish we can statically compile everything easily :P
<FromGitter> <luislavena> @sdogruyol is not impossible, but takes a lot of effort
<FromGitter> <sdogruyol> hehe
<Papierkorb> I'm not sure that you actually want to
<FromGitter> <luislavena> get a musl build of LLVM and also libraries targetting it to is also possible
<RX14> see this is why I hate the omnibus, it seems needlessly complex to me
<FromGitter> <luislavena> @RX14: not only to you. All the Chef stuff and friends is just a nightmare to work with.
<Papierkorb> I really appreciate it when applications do use my systems up-to-date OpenSSL
<RX14> Papierkorb, you can statically compile some things while not others
<Papierkorb> RX14: was responding to <sdogruyo_l> i wish we can statically compile everything easily :P
<FromGitter> <sdogruyol> :)
<FromGitter> <luislavena> I used to compile openssl+zlib and other statically but then on every update of these things I had to re-release binaries of my app, even when there weren't changes
<FromGitter> <luislavena> that is the problem with static compilation :tongue:
<RX14> depends whether it's a CLi thing or not
<RX14> well more like
<RX14> is it your application to deploy
<RX14> or are you distributing the binaries
<RX14> if you control the infra you might as well statically compile everything
<FromGitter> <luislavena> CLI apps that interface with API services
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<travis-ci> crystal-lang/crystal#3e1abe3 (master - Merge pull request #4076 from karlseguin/feature/empty_named_tuple_to_h): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/209894357
<DeBot> https://github.com/crystal-lang/crystal/pull/4076 (Calling an NamedTuple#to_h on an empty now has meaningful error message)
mjago has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
Ven has quit [Ping timeout: 260 seconds]
Ven has joined #crystal-lang
<RX14> I don't know how
<RX14> but this segfault is dumping uninitialized memory
<RX14> and i got a chunk of examples/havlak.cr
<RX14> which is so weird
<RX14> as this is a compiled binary
<RX14> i don't understand where that could even get in to the source
<RX14> or memory
<RX14> and the whole thing is teetering on the ege, such that if I change one miniscue thing the whole thing stops working
<travis-ci> crystal-lang/crystal#8a437e6 (master - Add Crystal::LLVM_VERSION to docs (#4123)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/209895493
<DeBot> https://github.com/crystal-lang/crystal/pull/4123 (Add Crystal::LLVM_VERSION to docs)
Ven has quit [Ping timeout: 260 seconds]
<RX14> "Program received and didn't handle signal ILL (4)"
<RX14> w h a t
Ven has joined #crystal-lang
<Papierkorb> crystal go to bed, you have fever hehe
<RX14> i don't even understand
<RX14> SIGILL is for an invalid instruction
<Papierkorb> guess what :D
<RX14> ?
<Papierkorb> are you sure llvm didn't produce a broken instructino?
<RX14> yes
<RX14> because it's intermittent
<RX14> same binary
<RX14> run multiple times
<RX14> always random results
<RX14> this is insane
<RX14> Papierkorb, if I delete the e off the end of the constant in L13 it stops segfaulting
<RX14> *thats* how weird this is
<Papierkorb> sounds a bit like a padding error
<Papierkorb> Though I wouldn't know which instruction might be doing that
<Papierkorb> at least some SSE instructions don't like unaligned access. I don't remember though if linux signals that through a SIGILL or SIGBUS or other
<RX14> nice
<RX14> i bet that won't segfault for you Papierkorb
<RX14> Papierkorb, but changing the "e" to a "n" fixes the segfault too
<RX14> so it's not length
<Papierkorb> it crashes because JSON doesn't like empty-string as input. I also had to change the $HOME path
<Papierkorb> no other issue after running it a bunch of times in release mode
<RX14> yes it crashes
<RX14> but it doesn't segfault
<RX14> it segfaults while raising for me
<Papierkorb> looks fine on my end
<RX14> I can reproduce it with my dir
<RX14> even if I move it
<RX14> let me try recreating the directory layout in code
Ven has quit [Ping timeout: 264 seconds]
Ven has joined #crystal-lang
bjz has joined #crystal-lang
mjago has quit [Ping timeout: 260 seconds]
<RX14> YES
<RX14> i reproduced the segfault with a freshly-cloned crystal
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 240 seconds]
<RX14> Papierkorb, still here?
<Papierkorb> yes
<RX14> a few times
<RX14> I can reproduce from scratch with that code
<Papierkorb> mom
<RX14> ?
<Papierkorb> Crystal 0.20.5 (2017-01-25), no issues
<RX14> Papierkorb, i'm on 0.21.1
<RX14> i don't see an issue on 0.20.5 either fwiw Papierkorb
<Papierkorb> Wow --release building using my git crystal takes ages
<RX14> hmm
<Papierkorb> Err .. is that the broken checkout?
<RX14> ?
<Papierkorb> might be that it's a broken build I had. let's retry with that one ..
<RX14> master tip works
<RX14> also no release needed
<RX14> (for me ofc)
<Papierkorb> Crystal 0.20.3+291 [8a437e67b] (2017-03-11) LLVM 3.9.1 - no issues
<Papierkorb> dunno why it advertises as 0.20.3, i just pulled master
<RX14> like
<RX14> when you run it what do you see?
Ven has quit [Ping timeout: 240 seconds]
<Papierkorb> without --release
<Papierkorb> the __libc_start_main address changes all the time, apart from that, same output every time
<RX14> eugh what
<RX14> i have same llvm ver and commit sha1 as you
<RX14> for the compiler build
<RX14> and I can repro
<RX14> how about
<RX14> try running it in /tmp/ Papierkorb
<Papierkorb> wanna have my binary?
<RX14> mkdir /tmp/foo; cd /tmp/foo then run the binary
<Papierkorb> still happy
<RX14> so I have an unreproducible bug
<RX14> great
Ven has joined #crystal-lang
<RX14> Papierkorb, well i'll take your binary then
<Papierkorb> there you go
<Papierkorb> RX14: Now it crashes
<Papierkorb> > Invalid memory access (signal 11) at address 0x74c935dd
<RX14> YES!