Svenskunganka has quit [Ping timeout: 268 seconds]
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 260 seconds]
Svenskunganka has joined #crystal-lang
Svenskunganka has quit [Ping timeout: 240 seconds]
<wmoxam>
hrmm, is it not possible to compile 0.21.0 by using 0.20.5 ?
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 240 seconds]
phase_ has quit [Remote host closed the connection]
snsei has joined #crystal-lang
msg has joined #crystal-lang
msg is now known as Guest97815
Svenskunganka has joined #crystal-lang
Guest97815 has quit [Ping timeout: 240 seconds]
Svenskunganka has quit [Ping timeout: 260 seconds]
VectorGraphics has joined #crystal-lang
msg has joined #crystal-lang
msg is now known as Guest66785
<VectorGraphics>
Hello. I'm trying out Crystal and am trying to wrap my head around what exactly is happening in a given scenario. If I do the following, then I get an error:
<VectorGraphics>
num = "123-456-7890".match(/[0-9]+/)
<VectorGraphics>
puts num[0]
<VectorGraphics>
But if I check if num is not nil around the puts, it's fine
<VectorGraphics>
Is Crystal checking to see if a condition is being checked for as a precaution?
Guest66785 has quit [Ping timeout: 240 seconds]
<sija>
`String#match` returns nilable `Regex::MatchData` so you either need to wrap it in `if` condition (like `if num = ...`) or use `#not_nil!`
<sija>
u might also want to check `String#scan`
<VectorGraphics>
Ah, so it depends on the potential return types since any given function may be able to return multiple types depending on how it's defined
<sija>
exactly
<VectorGraphics>
scan makes sense too. I did use that in ruby. Makes sense that it's in Crystal
<VectorGraphics>
Thank you :)
<sija>
uw, cheers! :)
soveran has joined #crystal-lang
<VectorGraphics>
I guess a follow-up question would be: what's the way to see return types for any given function?
<FromGitter>
<rishavs> does crystal have an explicit function return, or is it implicit (last statement) only?
<sija>
it's implicit, just like in Ruby
<sija>
there's `return` for explicit cases too
<FromGitter>
<rishavs> thanks
snsei has quit [Remote host closed the connection]
msg has joined #crystal-lang
msg is now known as Guest10545
Svenskunganka has joined #crystal-lang
Svenskunganka has quit [Ping timeout: 240 seconds]
akwiatkowski has joined #crystal-lang
zaiste has joined #crystal-lang
bjz has joined #crystal-lang
Guest10545 has quit [Remote host closed the connection]
msg has joined #crystal-lang
msg is now known as Guest88639
VectorGraphics has quit [Quit: Leaving]
Guest88639 has quit [Remote host closed the connection]
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 240 seconds]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
<FromGitter>
<rishavs> btw, is there a shorter notation for writing something like ⏎ ⏎ ```get "/p/index" do |env| ⏎ index_items (env) ⏎ end``` ⏎ ⏎ Maybe something like (hypothetical) `get "/p/index" as env >> index_items` [https://gitter.im/crystal-lang/crystal?at=58afeb41f1a33b6275421196]
<FromGitter>
<sdogruyol> nope
<FromGitter>
<rishavs> aww :(
akwiatkowski has quit [Ping timeout: 260 seconds]
<FromGitter>
<schoening> @rishavs You could do, I think? get "/p/index { |env| index_items(env) } ⏎ But that code is pretty short as it is :smile:
<FromGitter>
<rishavs> @schoening , yeah will probably leave it as is. I thought crystal had function chaining for some reason. :D
bjz_ has joined #crystal-lang
<FromGitter>
<schoening> I hope it does o_o ! If you return self?
<FromGitter>
<schoening> @rishavs I was thinking about how one would go about creating lodash in crystal :smile:
bjz has quit [Ping timeout: 268 seconds]
mark_66 has joined #crystal-lang
<FromGitter>
<rishavs> wrong person. :D i am still struggling through the basics
<FromGitter>
<rishavs> btw, how is your a* coming along?
<FromGitter>
<schoening> @rishavs same, but you know lodash, you use js right?
<FromGitter>
<molovo> @schoening what features in particular did you want from lodash? I think most of them are in the stdlib already
<FromGitter>
<schoening> I'm not making a* right now @rishavs, I am making "just-find-some-path"star :smile: it is going well :D changing it a lot!
<FromGitter>
<schoening> @molovo I don't think I need any features, I was just wondering if it could be done :p
<FromGitter>
<molovo> @schoening anything can be done if you have enough dev time ;)
<FromGitter>
<rishavs> @schoening , i think you can easily setup macros for them?
<FromGitter>
<schoening> haha! @molovo
<FromGitter>
<rishavs> @molovo , not always. i have enough dev time, still stuck on hello world programs
<FromGitter>
<rishavs> :D
<FromGitter>
<schoening> Maybe? I haven't gotten into macros beyond "property" (I think its a macro)
Svenskunganka has joined #crystal-lang
<FromGitter>
<dreyks> @rishavs this means you just need "more" time. like months. i mean till you figure out how to do what you want
<FromGitter>
<rishavs> yep. i do. i am not a coder by trade so pretty much everything i know is theoritical
<FromGitter>
<rishavs> so i have weird gaps in my knowledge
Svenskunganka has quit [Ping timeout: 255 seconds]
akwiatkowski has joined #crystal-lang
Guest24 has joined #crystal-lang
Guest24 is now known as Nouv
<Nouv>
Heyo
Nouv is now known as Guest84151
Guest84151 has quit [Changing host]
Guest84151 has joined #crystal-lang
<crystal-gh>
[crystal] muscar opened pull request #4074: Pass the filename in the codegen debug spec (master...pass-filename-in-codegen-spec) https://git.io/vyf7a
Guest84151 is now known as Nouv
<Nouv>
Two questions - what does having a `getter` at class level mean (I can't find that syntax in the docs or API), and where does the `STDOUT` class come from? I can't find that either
<FromGitter>
<dreyks> getter generates a getter for an instance variable
<FromGitter>
<dreyks> `property` generates getter and setter
<Nouv>
dreyks: I thought it would be that, but where is that mentioned in the api!?
<Nouv>
Actually the baked file system looks great too
Philpax has quit [Ping timeout: 268 seconds]
soveran has quit [Ping timeout: 260 seconds]
<FromGitter>
<schoening> OMG yay :D
<FromGitter>
<schoening> @rishavs the pathfinder works now :D
<FromGitter>
<schoening> No more crashing
Raimondii has joined #crystal-lang
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
Svenskunganka has joined #crystal-lang
<FromGitter>
<sdogruyol> @schoening good job
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
<FromGitter>
<schoening> Thanks @sdogruyol I read through @yxhuvud code example he linked to me and I think I am only using structs now.. (I'm not sure because I haven't figured out if arrays of structs are also allocated on the stack, or if the array containing them is on the heap)
<FromGitter>
<sdogruyol> structs are allocated at the stack
<FromGitter>
<schoening> So when I do something like items = Array(NamedTuple(x: Int32, y: Int32)).new it's also on the stack right?
Svenskunganka has quit [Ping timeout: 268 seconds]
Svenskunganka has joined #crystal-lang
Svenskunganka has quit [Ping timeout: 255 seconds]
<FromGitter>
<schoening> @sdogruyol is serving static files with kemal and crystal 0.21 open issue? It broke for me when I updated crystal
Guest32972 has quit [Quit: gotta go guys.]
pawnbox has joined #crystal-lang
<FromGitter>
<sdogruyol> @schoening please use Kemal 0.18.2
<FromGitter>
<sdogruyol> it's still an issue in Crystal yet we monkey patched it in Kemal 0.18.2
<Nouv>
What does {{ }} syntax mean? I can't find it in the docs
<Nouv>
ezrast: So the code within {{ }} is run at compile time?
<Nouv>
How am I screwing up this variable reference in the macro? https://dpaste.de/r7T2
<FromGitter>
<schoening> How can I downgrade to 0.18.2 *sudo apt-get install crystal=0.18.2* says that the version was not found. ⏎ Do I have to build from a tarball ?
<FromGitter>
<ezrast> change `def` to `macro` and get rid of the type annotation (arguments to macros are just AST nodes with no further typing AFAIK)
<Nouv>
ezrast: That worked, thank you
<Nouv>
ezrast: I thought a def was automatically marked as a macro if it contained {{ }} stuff?
soveran has quit [Remote host closed the connection]
<FromGitter>
<ezrast> It's a "macro method" which is different from a "macro" (the docs are not real clear on this). Macro methods can do some macro expansions but they don't have access to method arguments, since those are determined at runtime.
soveran has quit [Remote host closed the connection]
<FromGitter>
<rishavs> @schoening , congrats! i will also be rolling my crsfml based engine in the next few months. once i feel comfornatble enough with crystal.
Nouv has quit [Quit: My MacBook Air has gone to sleep. ZZZzzz…]
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
sz0 has quit [Quit: Connection closed for inactivity]
<FromGitter>
<yxhuvud> @schoening arrays are allocated in the heap.
Guest24 has joined #crystal-lang
Guest24 has quit [Ping timeout: 255 seconds]
zaiste has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter>
<rishavs> i have got a weird problem. Chrome is corrupting my js file. when I open the file in chrome browser, i get just weird symbol characters. ON edge my page works fine.
<FromGitter>
<rishavs> Chrome just gives me `Uncaught SyntaxError: Invalid or unexpected token` in the console
mgarciaisaia has joined #crystal-lang
mgarciaisaia has left #crystal-lang [#crystal-lang]
<FromGitter>
<rishavs> ok, chrome is unable to handle the multiline comments in the semantic js file :laughing:
<FromGitter>
<rishavs> ok, i replaced the comments and it is working again now. the ways of the web are arcane to me....
<FromGitter>
<rishavs> i am assuming it was a weird cache issue
<txdv>
this is one of the magic resistance games
zaiste has joined #crystal-lang
NIk-- has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 240 seconds]
<FromGitter>
<schoening> @yxhuvud hmm.. but arent u heap allocating stuff in aoc13 search function? I updated my code quite a bit (half the length!) and switched to NamedTuples and Hashes. https://github.com/schoening/pathfinder/blob/master/pathfinder.cr ⏎ I no longer get GC complaints. But I ran a Benchmark vs my old version and the new one is actually a lot slower o_o'... ⏎ Could you perhaps take a look, when you have the time?
Guest24_ has joined #crystal-lang
Guest24_ is now known as Nouv
Nouv has quit [Changing host]
Nouv has joined #crystal-lang
<Nouv>
Can Crystal handle non utf-8?
<FromGitter>
<asterite> What's non utf-8?
<Nouv>
I'm getting `Unexpected byte 0x89 at position 0, malformed UTF-8` when trying to read an image file
<FromGitter>
<asterite> Are you using Crystal 0.21.0?
<Nouv>
0.20.5
<Nouv>
Huh
<Nouv>
Did 0.21.0 come out like yesterday?
<FromGitter>
<asterite> Kind of, yes :-)
<FromGitter>
<asterite> A few days ago
<FromGitter>
<asterite> In any case, what do you need to do with that image file?
<FromGitter>
<yxhuvud> Nouv: read it as a slice instead of as a string.
<Nouv>
asterite: I'm embedding assets
<Nouv>
asterite: It works with 0.21.0, thanks!
<FromGitter>
<asterite> Great! :-)
<FromGitter>
<asterite> data...
<FromGitter>
<asterite> Yes, embedding assets became possible in 0.21.0 because string literals can now express arbitrary date
<Nouv>
asterite: I'm making a simple web app (as a learning exercise), and the idea of packaging all of the assets into the app so that you can distribute it as a single executable appeals to me
<Nouv>
Is there any way to check if the current running program was built for release?
<FromGitter>
<asterite> {% if flag?(:release) %} ... {% end %}
<Nouv>
asterite: Thanks!
<Nouv>
I was checking the ENV, didn't think about flags
unshadow has joined #crystal-lang
<unshadow>
Is there a way to use epoll in Crystal for sockets or does 'select' is the only one avilable ?
snsei has joined #crystal-lang
bjz_ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter>
<drosehn> heh. it just occurred to me that I haven't built any of my programs for release, even though I have a few crystal programs that I'm running all the time.
DeBot has joined #crystal-lang
unshadow has quit [Quit: leaving]
greengriminal has joined #crystal-lang
<Nouv>
How do I share variables between files? I have a cache variable that I need to access from multiple files (I have one route per file, using Kemal)
pawnbox has joined #crystal-lang
<FromGitter>
<yxhuvud> You use a CONSTANT.
<FromGitter>
<fridgerator> kemal-sessions ?
<FromGitter>
<fridgerator> store the value in something like redis?
<Nouv>
yxhuvud: Thank you!
zaiste has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<Nouv>
Can you overload constructors? I want optional named arguments
<Nouv>
Actually never mind
zaiste has joined #crystal-lang
Svenskunganka has joined #crystal-lang
Svenskunganka has quit [Ping timeout: 260 seconds]
greengriminal has quit [Ping timeout: 268 seconds]
greengriminal has joined #crystal-lang
<crystal-gh>
[crystal] MakeNowJust opened pull request #4075: Add simplest TTY detection for Colorize (master...fix/colorize/tty-detection) https://git.io/vyJoL
snsei has quit [Remote host closed the connection]
<FromGitter>
<josephljohnston_twitter> @asterite Sorry for the late reply, and thanks for your answer yesterday.
<FromGitter>
<josephljohnston_twitter> Anyone have thoughts on the challenges of building a unikernel with crystal? In particular what comes to mind is using crystal's C bindings to integrate with something like the Xen mini-OS to paravirtualize with the Xen on ARM ABI. Considering MirageOS's success with Ocaml, I think similar success is possible with crystal. I also think a much larger community of developers would be excited to build unikernel
<FromGitter>
... services with crystal than ocaml. I wish I had the confidence to pursue this project alone. If anyone has interest or advice, please let me know! (If any of these terms are unfamiliar, a quick google should give clarification).
soveran has quit [Remote host closed the connection]
mark_66 has quit [Remote host closed the connection]
<FromGitter>
<drosehn> I'd like to see that, but I would not want to start in earnest until crystal is officially past version 1.0.
<FromGitter>
<drosehn> (and as I've mentioned in past topics, I already have so many projects that I'd like to do, that I can't claim to have any time for writing a unikernel, even though I like the idea of trying that)
<FromGitter>
<asterite> Crystal is for high-level applications, not for writing kernels or OSs
<FromGitter>
<josephljohnston_twitter> @drosehn Just as many serious projects are being pursued with crystal before 1.0, I imagine this one can be as well. The primary task is the gluing part with crystal's C FFI. The rest of crystal can change dramatically and as long as stuff like a TCP stack remains available, the unikernel platform is available. But I understand your position.
<FromGitter>
<josephljohnston_twitter> @asterite That's what people say about Ocaml, which also has a GC.
<FromGitter>
<asterite> Is there a serious, popular OS written in ocaml?
<FromGitter>
<josephljohnston_twitter> No, but an OS is different than a unikernel. The base of the unikernel can be done in C and then interface with Ocaml, or Crystal, or ...
<FromGitter>
<drosehn> I'm sure this one could be started now. I'm just saying that I wouldn't be the person working on it. :smile:
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
<RX14>
considering there are working OSes in crystal which boot - it's certainly possible
<RX14>
it's not easy
<RX14>
crystal isn't designed for it
<RX14>
and starting is a pain in the arse
<RX14>
but it's possible
<FromGitter>
<rishavs> ok, i now have working CRUD web app. now i want to get started with auth. i want to use google login for users to view and edit their posts. Do any of you know of good beginner articles/resources that I can pick?
greenbigfrog has quit [Ping timeout: 240 seconds]
akwiatkowski has joined #crystal-lang
adam12 has quit [Ping timeout: 264 seconds]
adam- has joined #crystal-lang
adam- is now known as adam12
adam12 is now known as Guest4306
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 240 seconds]
<crystal-gh>
[crystal] karlseguin opened pull request #4076: Calling an NamedTuple#to_h on an empty tuple returns {} of Symbol => Nil (master...feature/empty_named_tuple_to_h) https://git.io/vyJdo
<FromGitter>
<schoening> I have a hard time googling this.. Is there a performance difference between stack and heap instances after allocation? Like using an object pool
<Papierkorb>
difference in access speed you mean?
pawnbox has joined #crystal-lang
Guest4306 is now known as adam12
mgarciaisaia has joined #crystal-lang
pawnbox has quit [Ping timeout: 255 seconds]
mgarciaisaia1 has joined #crystal-lang
mgarciaisaia has quit [Ping timeout: 255 seconds]
gloscombe has quit [Ping timeout: 240 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 260 seconds]
pawnbox has joined #crystal-lang
elia has joined #crystal-lang
<FromGitter>
<rishavs> any gists or examples of anyone using kemal-basic-auth and kemal-sessions?
mgarciaisaia1 has left #crystal-lang [#crystal-lang]
<jokke>
maybe there's someone here now who can help me :/
<jokke>
i have no idea what the problem might be
<FromGitter>
<schoening> @Papiercorb yeah, I know stack allocations are faster, ive gotten that far, but is there any difference in updating the data once it is allocated? I think not?
<BlaXpirit>
schoening, yes, there is difference. if you have objects close together and read them in order, the cpu works faster, hits cache more often, whatever
<Papierkorb>
schoening, there should not. But as always, you should benchmark it. Crystal comes with the "benchmark" library which you can use for this to do it easily
Svenskunganka has joined #crystal-lang
elia has quit [Quit: Computer has gone to sleep.]
<Papierkorb>
schoening, and stack allocations may be faster, but in reality, stack and heap allocations have vastly different use-cases, so it quickly becomes a comparisong between apples and oranges
<FromGitter>
<schoening> @Blaxpirit ah, yeah I think I saw a talk of that once by a ps4 dev. I look more into it
Svenskunganka has quit [Ping timeout: 240 seconds]
<BlaXpirit>
but i should mention that this is not about stack specifically, you could allocate a big memory region in the heap just as well, though crystal does not make it convenient
<Papierkorb>
schoening, if you do benchmark it, compare a StaticArray against a Slice or Array, each with a size >32Bytes. If you only have a struct with a single Int32 in it (for example), LLVM may optimize that thing down to not exist, in which case you'd benchmark your CPU accessing a register
<FromGitter>
<schoening> Yeah I am doing some benchmarking, the tool is awesome @Papierkorb! I am just stuck at my current pathfinder implementation and since I don't know the language well yet I am poking around how to improve
<BlaXpirit>
i think StaticArray vs Slice makes no difference, it's more about whether it contains pointers to random locations in the heap (`class`) or puts the objects right there one after the other (`struct`)
<FromGitter>
<schoening> Thx for the tip @Papierkorb. I had something similar happen earlier today when both my benchmarks where insanely fast and equal. Was coz I repeated with the same input so I think llvm removed it
<jokke>
maybe some hints where to start debugging this? The code compiles, links and runs fine on arch linux. I need the trusty image, since the default travis image has an ancient version of gpgme which my code won't link against...
<BlaXpirit>
jokke, where to start debugging: try to get a system close to what travis has
<BlaXpirit>
also have you tried sudo: false
<jokke>
sudo: false is default
<BlaXpirit>
uhm then sudo: required
<jokke>
one possibility would be to use sudo: true and then install a recent gpgme version from a deb package, that's right
<jokke>
but no idea if it plays nice with all the shared libs
<BlaXpirit>
yeah but i mean it could work even without doing that
<BlaXpirit>
who knows what magic they're doing there
<BlaXpirit>
i just couldnt find it at all :p so i believed
<jokke>
hm
<jokke>
oh
<jokke>
lol
soveran has quit [Remote host closed the connection]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
<jokke>
hm
<jokke>
seems like travis doesn't support running inside a custom docker image
pawnbox has quit [Ping timeout: 268 seconds]
dhk_ has joined #crystal-lang
dhk has joined #crystal-lang
<FromGitter>
<Rinkana> It sould work just fine, our whole company uses travis & docker
zaiste has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
akwiatkowski has quit [Ping timeout: 260 seconds]
dhk has quit [Quit: Leaving]
pawnbox has joined #crystal-lang
soveran has joined #crystal-lang
<BlaXpirit>
i think if u use docker on travis, you're supposed to use ONLY docker - also run your tests with it, you cannot use normal travis configs and bash stuff
<BlaXpirit>
wow, some pretty gnarly stuff here. my project (admittedly crazy as usual) worked fine before but crashes 0.21 compiler
<Yxhuvud>
nice
<BlaXpirit>
git bisect was not decisive because some revisions cause a compiler crash and others cause a compilation failure (might be compilation of crystal itself)
greenbigfrog has joined #crystal-lang
<Yxhuvud>
my project survived the upgrade :ÖP
<BlaXpirit>
but yeah, 4c6708cc033f090746692c0614f534f3895d0eba is the first bad commit "LLVM: bind Context functions, and apply a general refactor" - that would do it :p
<BlaXpirit>
sigh i'm gonna make an issue with just minimal info, making a minimal reproduction would be sooo annoying
<FromGitter>
<Rinkana> That feeling when you've been searching for a bug for hours and its in your face almost the whole time...
Svenskunganka has joined #crystal-lang
elia has joined #crystal-lang
<FromGitter>
<maxpowa> @ysbaddaden I'm having an issue getting TTF working in SDL.cr, specifically it's segfaulting whenever I try to do `TTF::Font.new`, is TTF supposed to be working or is it still wip?
Svenskunganka has quit [Ping timeout: 260 seconds]