<sauer2>
Phew, it works without Nil. Thank you @bew !
<FromGitter>
<bew> I think that in a BlockStatement there should be an array of Statement, it feels logic. IMO if you don't always have statements in a BlockStatement, it that there is something wrong in how you use your data structures, and that something should be fixed, not by changing the data structure but adding a check where needed
<FromGitter>
<bew> you're welcome ;)
<sauer2>
it is, now, along with some more of those cases.
<sauer2>
Well, see you around.
sauer2 has quit [Quit: Page closed]
<FromGitter>
<bew> yep! going to sleep now, see'you
Aytan72 has quit []
<FromGitter>
<luislavena> @mgarciaisaia @bcardiff any ETA release of binaries for 0.23.0?
<FromGitter>
<mgarciaisaia> It should have been *today*, but running into some issues - tomorrow, hopefully?
<FromGitter>
<luislavena> @mgarciaisaia I think I can survive one more day :wink:
<FromGitter>
<luislavena> Thank you for the quick response! :smile:
<FromGitter>
<mgarciaisaia> Lucky me :)
<FromGitter>
<johnjansen> ok this could be a dumb question, but how do you test an IO for EOF? (without falling back to exceptions)
foca has quit [Ping timeout: 240 seconds]
z64 has quit [Ping timeout: 240 seconds]
foca has joined #crystal-lang
z64 has joined #crystal-lang
<crystal-gh>
[crystal] MakeNowJust opened pull request #4631: Format: show backtrace when formatting bug found (master...fix/crystal-format/show-backtrace-when-bug-found) https://git.io/vQcwW
rohitpaulk has joined #crystal-lang
Kug3lis is now known as Kug3lis_off
Kug3lis_off is now known as Kug3lis
Kug3lis is now known as Kug3lis_off
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 260 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter>
<krypton97> Is there an auto formatter extension for crystal?
<FromGitter>
<bew> There is : crystal tool format
<FromGitter>
<sdogruyol> crystal tool format
<FromGitter>
<bew> :)
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 260 seconds]
rohitpaulk has joined #crystal-lang
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
<FromGitter>
<akzhan> @faustinoaq you may be allowed to —cross-compile x86_64-macosx-darwin
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
flaviodesousa has joined #crystal-lang
snsei has joined #crystal-lang
snsei_ has joined #crystal-lang
snsei_ has quit [Client Quit]
snsei has quit [Ping timeout: 258 seconds]
<FromGitter>
<krypton97> Is crystal tool format same as gofmt aka formats the code on saving
<FromGitter>
<bew> the crystal formatter is a formatter, it doesn't do anything on his own. However you can configure your editor to format the file everytime you save it!
<FromGitter>
<krypton97> Nice
<FromGitter>
<krypton97> That's what I wanted to know, ty
<FromGitter>
<akzhan> @krypton97 Almost every Crystal language IDE plugin allows to format on save. And you may run it by yourself too.
<FromGitter>
<lilijreey> @akzhan Is there have any document that Crystal design?
<FromGitter>
<bew> what do you mean by "document that crystal design" ?
<FromGitter>
<lilijreey> @bew Crystal Language design paper
<FromGitter>
<bew> oh, I don't think there is such a paper ATM, it's all in crystal core dev team's heads, but it would be good to have it written down!
<FromGitter>
<sdogruyol> hey everyone
<FromGitter>
<sdogruyol> how are you?
<FromGitter>
<bew> fine! & you?
<FromGitter>
<lilijreey> me to
<FromGitter>
<sdogruyol> great
<FromGitter>
<sdogruyol> @lilijreey welcome
<FromGitter>
<lilijreey> @bew How to become crystal core developer ?
<FromGitter>
<lilijreey> @sdogruyol Thx :smile:
<FromGitter>
<sdogruyol> @lilijreey contribute to Crystal and do a lot of pull requests :)
<FromGitter>
<lilijreey> @sdogruyol Right :+1:
<FromGitter>
<sdogruyol> @lilijreey what's your current programming language of choice?
<FromGitter>
<lilijreey> I need learning LLVM first. I new user Java for web dev. But I'am not like java. I used to C++/Ruby/Erlang/Lua
<FromGitter>
<lilijreey> dislike not 'not like' 哈哈
<FromGitter>
<bew> cool a Lua guy ;)
<FromGitter>
<sdogruyol> yeah
<FromGitter>
<sdogruyol> wish i knew some chinese :P
<FromGitter>
<sdogruyol> japanese would be okay
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
bjz has quit [Client Quit]
chimkan has joined #crystal-lang
chimkan has quit [Client Quit]
chimkan has joined #crystal-lang
chimkan has quit [Client Quit]
chimkan has joined #crystal-lang
<FromGitter>
<codenoid> sup
chimkan has quit [Client Quit]
<FromGitter>
<codenoid> how to get my current local ip address in crystal ?, like in linux i do `` ifconfig `` and i got ⏎ `` inet addr:192.168.100.12 `` ,
chimkan has joined #crystal-lang
<FromGitter>
<codenoid> and also, any body have example code crystal write file ? , thanks
<FromGitter>
<codenoid> ^^ like shell exec
<FromGitter>
<bew> what do you mean?
<FromGitter>
<codenoid> ok, 1.how to execute OS command on via crystal and get the result, 2. how to write file and edit file with crystal , thanks
<FromGitter>
<sdogruyol> Is there anything that the community can help with the release process
<FromGitter>
<sdogruyol> i'm curious about discovering more ways to improve colloboration between core team and the community
<FromGitter>
<mverzilli> with release in particular it is a bit complicated due to keys for repos and so on
<FromGitter>
<mverzilli> *this* release in particular is a bit more tricky because we made some changes to the omnibus scripts and are trying to get rid of llvm 3.5
<FromGitter>
<mverzilli> we're still aiming at one release per month, this one slipped to two months because of that
<FromGitter>
<bew> what is the omnibus thing exactly?
<FromGitter>
<sdogruyol> @mverzilli thanks for the info
<FromGitter>
<mverzilli> it's a set of scripts we use to generate crystal binaries and packages for the different target distros, os's, etc
<FromGitter>
<mverzilli> the process generally takes quite long, each time we try it it takes hours to do everything
<FromGitter>
<sdogruyol> @mverzilli what's required to make it faster / better?
<FromGitter>
<codenoid> sir, crystal wont directly read my file after i upload it
<FromGitter>
<codenoid> or crystal need some time ? sleep ?
<FromGitter>
<Freezerburn> What's the correct way to use Dir.blob to get all files recursively in a specific directory? I attempted to use "Dir.blob [File.join(dir_one, dir_two) + "/**/*"]", but that didn't give me any files. Subsequently: Is blob documented anywhere?
<FromGitter>
<codenoid> same :(
chimkan has joined #crystal-lang
<FromGitter>
<codenoid> oh
<FromGitter>
<codenoid> ah silly mistake
<FromGitter>
<bew> @Freezerburn try `Dir["**/*"]`
<FromGitter>
<codenoid> read function inside write function
chimkan has quit [Client Quit]
<FromGitter>
<bew> (which is the same as `Dig.glob "**/*"`, and it's `glob` not `blob`)
hightower has joined #crystal-lang
chimkan has joined #crystal-lang
<FromGitter>
<sdogruyol> i'd really really like to have something like this for Crystal https://github.com/mitchellh/gox //cc @RX14
<FromGitter>
<codenoid> :sparkles:
<FromGitter>
<Freezerburn> @bew I think not using a code tag or something ate the double star I put in. The problem I'm having is that using `**/*` doesn't allow me to specify the exact dir I want to list all the files for. Do I need to cp to the dir first, or is there a way to do `Dir[someDir + "**/*"]`?
<FromGitter>
<Freezerburn> `Dir[someDir + "/**/*"]`, rather
<FromGitter>
<bew> well, `Dir.glob "/tmp/**/*.cr"` works
<FromGitter>
<bew> you might prefer to use `Dir.glob File.join("/tmp", "**/*.cr")`
<FromGitter>
<bigtunacan> @sdogruyol How is that different from the built in --cross-compile?
<Papierkorb>
krypton97, 1) #loop is already defined 2) brackets around conditions are superfluous 3) Use `10.times do |i| ... end` instead
<Nouv>
Was the crystal parser written by hand?
<Papierkorb>
Nouv: Yes
<Nouv>
Wow
<Papierkorb>
krypton97, Or `0.upto(9) do |i| ... end` if you like that more
<Papierkorb>
Nouv: ?
<Nouv>
parser.cr is one complicated file
<Nouv>
Papierkorb: Is it recursive descent?
<Papierkorb>
As is any parser, generated or not
<Nouv>
Fair
<FromGitter>
<krypton97> thank you all, I fixed it based on compiler output till the end
<FromGitter>
<bew> no, not recursive descendent :/
<Papierkorb>
Nouv: Yes it is, as is usual for a handwritten one. thus it's LL(k), may be LL(1) even
<FromGitter>
<bew> is it? Oo
<Papierkorb>
What else?
<Papierkorb>
It's not table driven, that's for sure
<Nouv>
Could have been top down order precedence?
<FromGitter>
<bew> Papierkorb, oh yes, mixed it with PEG parser
<FromGitter>
<sdogruyol> @Nouv are you a compiler person? :)
rohitpaulk has quit [Ping timeout: 255 seconds]
<Nouv>
@sdogruyol: Trying to learn! I think I understand basic lexing and parsing (recursive descent), now looking into semantic analysis. Yourself?
<Papierkorb>
Nouv: Have a look at the semantic/ sub-dir, tons of visitors for that in there
<Nouv>
Ooh
<Yxhuvud>
Papierkorb: there is different hard when it comes to parsers though. compare to parse.y in the ruby source tree. You may want to get protective gear for your eyes first though
<Papierkorb>
Yxhuvud: The #ifdefs for ripper are really the finishing touch
<FromGitter>
<fridgerator> @drujensen thats cool!
<Nouv>
Yxhuvud: Oh my god
<Papierkorb>
Yxhuvud: I was referring at that such parser are by their nature complex, not that some are especially ugly
<Papierkorb>
Though yeah, ruby's .y is quite a treat lul
<Yxhuvud>
I wonder how much of that is due to the lack of power in the parser engines. Ie how much simpler could they be if it were built on something like Marpa?
<Nouv>
Where do things like IO (filesystem access for example) come in the compiler process? Is that something that LLVM deals with, or do you have to write assembly? Terrible question I know
Kug3lis is now known as Kug3lis_off
<FromGitter>
<krypton97> any way to workarround this?
<oprypin>
Nouv, file system access is done using Crystal, calling POSIX APIs
<FromGitter>
<krypton97> to puts the sum, but first and second yield takes only 1/2 args not 3
<FromGitter>
<krypton97> how can I cover all the cases?
<FromGitter>
<krypton97> if possible
<Nouv>
oprypin: I guess my question should then be - how does crystal interact with an api?
<oprypin>
Nouv, through C ABI - dynamically linked libc
<oprypin>
i think
<RX14>
Nouv, i suggest you read up about syscalls and libc
<Nouv>
RX14: Thanks! I know I have no idea about any of this, was looking for a direction to head in. I'll go for that, thanks!
<RX14>
Nouv, crystal's IO abstraction comes from the stdlib which calls into libc which executes syscalls
<RX14>
thats the high level
<Nouv>
RX14: And libc is linked using llvm?
<RX14>
libc is witten in C and crystal binaries dynamically link to libc
<RX14>
libc is likely compiled using gcc actually
<oprypin>
means how linking to crystal happens
<Papierkorb>
linked to the binary by your systems dynamic linker when you instruct your system to execute that binary
<RX14>
Nouv, you're touching on a lot of topics which go quite deep here, it's really quite hard to explain it so you truly understand it over public IRC
<Nouv>
Right, okay
<Nouv>
I have to go, but thank you for your help!
Nouv has quit [Quit: Nouv]
rohitpaulk has joined #crystal-lang
<hightower3>
Hey, how do I solve this: I want a function to take arbitrary number and type of args. I can do this with def func( *args) . However, I have trouble when I want to save that to some instance var like @args, since I must specify type, which I don't know in advance.
<hightower3>
Is this a solvable problem or simply can't be done?
<Papierkorb>
Generic, but for that you have to know the type in advance somehow ("educated guess"), OR if you're passing that to #initialize it can auto-deduce it, OR you go with the good old OOP Base-class-Generic-class container approach if you really really need this
<hightower3>
Papierkorb, how would #initialize work? I have def initialize(*args), but if I use (*@args) or if in the body I say @args= args, I get "Can't infer the type of instance variable '@args'"
<hightower3>
(Is this because I don't actually call it from anywhere yet, I just added that class/method?)
<Papierkorb>
Please gist the whole code of that class.
<hightower3>
Papierkorb, Mm, I would try to avoid using Arrays, because where I want to go with this is that when someone calls X.new.call( obj), I execute something like obj.call( @operator, *@argument). And I can't do *@arg if it's an Array
<hightower3>
Am I misdesigning how one would do this in Crystal, or?
<Papierkorb>
hightower3: we don't know what you're trying to build, thus we can't say if it's mis-designed or not
<Papierkorb>
hightower3: and my code serves as example, just change it to what you need
<hightower3>
An object where I store method name (@operator in my example) and intended arguments (*@argument). Then, when someone calls obj.call( other_obj), I want to invoke method other_obj.@operator( *@argument)
<Papierkorb>
That's not possible
<Papierkorb>
#send doesn't exist
<hightower3>
ok, thanks. I'll try getting around that with blocks then
<Papierkorb>
Sounds over-complicating/over-engineering to me
<Papierkorb>
If you have a "named" operator, and two objects you want to compare by it, why not have a simple method which takes the operator, a, b, then throws `operator` into a case statement and calls the operator method accordingly on a and b?
<Papierkorb>
If you want it fancier (for whatever reason), that case statement could return a Proc(T, Bool) like in `def f(op, a) case op when :< then ->(b){ a < b } end`
<Papierkorb>
But I'd prefer the first solution over the Proc-returning solution
<hightower3>
Papierkorb, right, I named it @operator but in general it can be any method
<hightower3>
What's the general solution for when I have something like: def x( arg : [] of SomeClass), and then due to arg being an Array I am unable to call *arg inside method body?
mooe has joined #crystal-lang
<hightower3>
Oh I see, in the specific case where I needed it, I see that Crystal supports saying array[from..to]= array2, and it does what I wanted to do by saying *array2
<hightower3>
Is 'x.class===Char' equal to x.is_a? Char ?
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
<FromGitter>
<dippersauce> For the life of me I cannot figure out the syntax for File's .new method ```new_file = File.new(old_file_path : new_text, 'w')``` throws a syntax error "expecting token 'CONST', not 'new_text'" Would someone be kind and inform me of the proper syntax?
<FromGitter>
<krypton97> are there packages that standardlib is missing/?
<FromGitter>
<straight-shoota> @dippersauce the method expects a filename as string and optionally a mode as string
<FromGitter>
<straight-shoota> if you want to write `new_text` to the file at `old_file_path` you can call `File.write(old_file_name, new_text)`
<hightower3>
Papierkorb, only Int once I am inside 'if idx'?
<Papierkorb>
hightower3: yes
<Papierkorb>
johnjansen, hightower3, straight-shoota, that #map is highly inefficient. Better would be: `[0, 0, 0] of Int32 | Bool`
<FromGitter>
<johnjansen> :-)
<FromGitter>
<straight-shoota> Yes, of course. I would have used `[0.as(Int32 | Bool), 0.as(Int32 | Bool),0.as(Int32 | Bool)]` as a more efficient way, but thats harder to read. ⏎ I actually didn't know that the literal with `of` works like that, really nice ;)
<FromGitter>
<johnjansen> neither did I, but on reflection its so obvious
<Papierkorb>
Same works for literal hashes
<FromGitter>
<straight-shoota> indeed
<hightower3>
Hm crap, https://carc.in/#/r/29rf works, so that means my specific problem is not related to #index but some other peculiarity of the code
<hightower3>
Appears I had to handle the case where list is nil, gotten further now
<hightower3>
Ooh, wonderful! Have a first solid piece of code written in Crystal that works/passes my spec tests
Nouv has joined #crystal-lang
<Nouv>
Could anyone please point me to where in the crystal source it handles syscalls?
<RX14>
Nouv, it doesn't, libc handles the syscalls
Nouv has quit [Ping timeout: 240 seconds]
<FromGitter>
<bew> more: kernel handle the syscalls, crystal only call them
<FromGitter>
<bew> no?
<RX14>
yes but i think that's what Nouv meant
Nouv has joined #crystal-lang
<Nouv>
I apologize for my appallingly bad connection .. if I DC again just fax me the answer or something.
<Nouv>
But yes, does anyone know where in the compiler syscalls are handled?
<RX14>
Nouv, libc handles the syscalls
<FromGitter>
<johnjansen> sorry no fax machine … i can do morse over LF
<Papierkorb>
Nouv: I think you're confusing the compiler with the "runtime"
<Nouv>
Papierkorb: Hm, my ignorance shows
<Nouv>
I thought the runtime was an interpreter thing?
<Papierkorb>
Nouv: The compiler doesn't handle it, it just (through LLVM) emits machine code for a CALL, or SYSCALL if you write one manually with inline assembler
<FromGitter>
<bew> oh no you right RX14, libc only wrap the syscalls, e.g. `write` is transformed to `syscall(SYS_write, ...);` or somethign close to that
<RX14>
@bew a bit more than that actually I think
<Papierkorb>
Nouv: Far from it, a runtime in itself is just something that runs under, or alongside, a running application, providing useful functionality to the running program
<RX14>
Nouv, the compiler turns crystal sourcecode into execurtable machinecode
<RX14>
the standard library is also written in crystal
<Nouv>
Papierkorb: Crystal is both a compiler and runtime then?
<Papierkorb>
Nouv: Crystal compiles (and links) code into real machine code, that stuff isn't interpreted anymore (well ...)
<RX14>
and parts of it are included in each crystal binary
<RX14>
none of the compiler is included in each crystal binary
<Papierkorb>
Nouv: the `crystal` program gives you access to the crystal compiler, and crystals standard library provides you with a runtime
<Papierkorb>
Nouv: You use `crystal` to build your program (source code -> ... -> binary), and that binary has no dependency on Crystal itself anymore (the compiler might as well have never existed). It contains however code from the stdlib.
<Nouv>
Ah I see
<RX14>
@johnjansen i never learnt morse... I should one day
<Nouv>
compiled code from the stdlib?
<Papierkorb>
Nouv: The stdlib is normal Crystal code, offering useful functionality to you for various tasks. E.g., the crystal program `puts "Hello"` uses the puts method provided by the stdlib to print a string on the screen
<Nouv>
I think I get that
<FromGitter>
<johnjansen> ``````
<Nouv>
Papierkorb: So the stdlib is the part of the program that handles syscalls?
<Papierkorb>
Nouv: The stdlib provides methods that may do syscalls, directly, or indirectly through another library (e.g. libc)
<Papierkorb>
Nouv: There's no "handling" of it, user space programs commonly do not implement syscalls
<Papierkorb>
Nor can they
<Nouv>
I suppose then that my question should be: when I compile the program `puts "Hello"`, how exactly does Crystal call into libc to print that?
<Nouv>
I don't know how to phrase it correctly but I think the basis of my question is how does IO happen at all
<RX14>
@johnjansen would be useful for my ham radio hobby
<RX14>
Nouv, well there's a write syscall that the kernel implements
<Papierkorb>
Nouv: Ok, create a file foo.cr, type `puts "Hello"` into it, then build it with this command: `crystal build --release foo.cr`
<RX14>
thats the basic starting point
<Papierkorb>
Nouv: I assume you have access to binutils, which you have when you're on Linux, BSD oder MacOS
<RX14>
libc will create a C function which calls this syscall and returns the result
<Nouv>
I'm on macOS
<RX14>
crystal links to libc and uses that syscalls
<Papierkorb>
Nouv: Executing that program `./foo` will print out "Hello", correct?
<Nouv>
Papierkorb: Right
<Papierkorb>
Nouv: Next, run this command: `ldd foo` this will print out all dynamic libraries your program depends on.
<Nouv>
Papierkorb: "Command not found" hah
<Papierkorb>
Nouv: Google says `otool -L foo` will do something akin to that
<Papierkorb>
Nouv: All of these libraries are *dynamically* linked by your systems kernel to make the program work, and then it's executed. You should see a line mentioning `libc` or so. That's the well known, not that magic (just a little bit...) libc we're talking about
<FromGitter>
<johnjansen> wow @RX14 nice work … see if you can raise ZL1MRC some time … he’s a good friend of mine
<FromGitter>
<RX14> haha new zealand's a bit far on 5 watts ssb
<Papierkorb>
Nouv: A symbol is a function (like fwrite), or a global variable (like errno). In that dump ^, you find all dynamic symbols our programs either requires from another dynamic library, or which it provides
<Papierkorb>
Nouv: You see tons of GLIBC mentions, yep, those are those we require from our libc (on my machine that is)
<Nouv>
Papierkorb: Right
<Papierkorb>
Nouv: On line 19 in my dump, you find `write`. Yep that's good ol' write(2)
<Nouv>
Papierkorb: So the generated code that calls the libc functions is in the llvm IR?
<Papierkorb>
Nouv: But look above, that code comes from: IO::FileDescriptor#unbuffered_write<Slice(UInt8)>:Int32 - That is, IO::FileDescriptor class, #unbuffered_write method, taking a single Slice(Uint8) as argument, returning a Int32
<Papierkorb>
Nouv: And on line 264, that is LibC.write, or our write(2)
<Papierkorb>
Nouv: Ok, and next thing write(2) does it it will itself do a platform specific SYSCALL (There are lists showing which platforms support which, including mapping, if you google for them), in this case, eventually, it'll do a SYS_WRITE into STDOUT
<Nouv>
Ahh
<Papierkorb>
Nouv: And that's the moment our "Hello\n" will be sent off to the kernel for it to be written, which will later on end up on our monitor screen
<Papierkorb>
Where you can enjoy the marvel that is of printing a few characters ;)
<Nouv>
:D
<Papierkorb>
Questions anyone?
rohitpaulk has joined #crystal-lang
<Nouv>
Papierkorb: Where is the class LibC defined?
<Papierkorb>
Nouv: that's not a class, but a `lib`, defined in Crystal
<Nouv>
Papierkorb: Thank you so much for taking the time to help me by the way, it would have taken me 10x longer to try to figure that out myself
<Papierkorb>
Nouv: https://github.com/crystal-lang/crystal/tree/master/src/lib_c they're platform dependent, so there are many. All should be equivalent however, and you as Crystal user shouldn't note any difference. You can just write `LibC.write(2, "Hello\n", 6)` in your `foo.cr`, run it, it'll behave exactly the same
<Papierkorb>
^ That is, file descriptor 2 (or STDERR, 1 is STDOUT), buffer "Hello\n", and 6 Bytes to write.
<FromGitter>
<bew> Nice deep short course Papierkorb !
<Papierkorb>
A few questions keep rising here, feel sometimes like I should just write a blog on stuff like that
<FromGitter>
<bew> or at least a wiki page for crystal with this ;)
<Nouv>
Papierkorb: And at runtime llvm links libc?
<Papierkorb>
Nouv: Throw that LLVM stuff out, at runtime, there's no LLVM anymore
<Nouv>
Okay, thrown
<Papierkorb>
Nouv: Your operating system kernel does the linking for you.
<FromGitter>
<bew> Are you sure about that?
<Papierkorb>
100%
<Papierkorb>
bew, though it's nothing you couldn't do in user-space using mmap() and mprotect() and, of course, an ELF reader (or whatever format you use)
<Nouv>
Papierkorb: does llvm play any role in this at all? Does it compile information telling the operator system kernel what to link?
<FromGitter>
<sdogruyol> @papierkorb you should definitely write these info down, or maybe a blog post would be a great great resource
rohitpaulk has quit [Ping timeout: 240 seconds]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter>
<straight-shoota> true, it's really informative to read all this stuff
<FromGitter>
<sdogruyol> it's gold
bjz has joined #crystal-lang
<RX14>
Nouv, what to link is part of the ELF object file which LLVM writes, so yes it does tell the linker what to link
<RX14>
in LLVM ir you specify external functions and you can tell use them
<RX14>
the lib definitions in crystal translate into those external function definitions in LLVM
<FromGitter>
<bew> Papierkorb, when I do `ldd /bin/cat` I get 3 lines, one is: `/lib64/ld-linux-x86-64.so.2` I thought it was responsible to find and load necessary dynamic libs
<FromGitter>
<bew> Papierkorb, it seems to be the first thing that load on program launch, then it load all dynamic libraries and finally it transfer control to the actual program
<FromGitter>
<krypton97> how can I use the ENV in my app?
<FromGitter>
<krypton97> I've tried as docs said but no success
<FromGitter>
<johnjansen> how do you want to use it?
<FromGitter>
<krypton97> passing a port for a server
<FromGitter>
<krypton97> I've tried this
<FromGitter>
<krypton97> const PORT = ENV["PORT"] || 3000
<FromGitter>
<bew> its `PORT = ENV["PORT"]? || 3000` the `?` will make the env lookup to return nil when it doesn't find PORT in the environement
<FromGitter>
<johnjansen> haha
<FromGitter>
<bew> that edit :)
<FromGitter>
<johnjansen> i was busy doing it while you dropped your code
<FromGitter>
<johnjansen> ;-)
<FromGitter>
<krypton97> still got issus tbh
<FromGitter>
<krypton97> but it's not a must for now
<FromGitter>
<krypton97> :D
<FromGitter>
<bew> what's the error?
<FromGitter>
<krypton97> ty
<FromGitter>
<krypton97> no overload matches
<FromGitter>
<krypton97> weird
<FromGitter>
<bew> can you show the full error?
<FromGitter>
<johnjansen> BTW i wouldnt use “PORT” as a name … its better to include the owner as part of the name
<FromGitter>
<johnjansen> i.e. “MY_WEB_SERVICE_PORT"
<FromGitter>
<krypton97> ok good to know
<FromGitter>
<elorest> in ruby I use `hash[“key”] || “some other value”` and `hash[“key”] ||= “some other value”` In crystal you have to do `hash[“key”]? || “some other value”` and `hash[“key”] ||= “some other value”` which seems a little inconsi
<FromGitter>
<johnjansen> what im about to say has no relationship to my friend @elorest’s example above … ⏎ ⏎ im perpetually horrified by the things that become apparent about common ruby code, once you try to compile it in crystal … (the stuff that should “just work” but doesnt because of multiple unexpected return types etc) ⏎ ⏎ even if crystal was only useful for finding bad ruby, it would be awesome … i
<FromGitter>
<elorest> Still it’s weird to me that `hash[“key”] ||= “some other value”` works in crystal but `hash[“key”] || “some other value”` doesn’t.
<FromGitter>
<johnjansen> yep, i hear you
<Papierkorb>
elorest, it's actually not inconsistent. All #[] in Crystal are expected to return something, or raise if nothing was found. #[]? returns something, or nil (question method, it asks if it's there). And #[]= sets it, it doesn't ask, it says "whatever there is already, x is now y"
<Papierkorb>
that's no-weird-bugs by default, and no #fetch orgies either
<FromGitter>
<elorest> <Papierkorb> But `hash[“key”] ||= “some other value”` is saying return the current value or set which seems inconsistent because `hash[“key”]` returns and exception if it doesn’t exist… so how does ||= work but || doesn’t?
<FromGitter>
<elorest> This would make sense to me if I could also do this `hash[“key”]? ||= “some other value” `
<Papierkorb>
heh I actually never needed that before, that I can understand
<FromGitter>
<elorest> You’ve never needed to return a hash value or a default if it didn’t exist?
<FromGitter>
<krypton97> what's the equivalent of sleep in crystal lang?
<FromGitter>
<bew> `sleep`
<FromGitter>
<elorest> `sleep`
<Papierkorb>
elorest, that I needed, but not ||=
<FromGitter>
<krypton97> I could've bet it will be sleep
<FromGitter>
<krypton97> lol
<FromGitter>
<elorest> Ok. I’ve been doing ruby since 05 and I use both all the time. I also see both used in crystal in multiple libraries including the stdlib. It’s just weird to me that they’re different… I understand it being different from ruby but it’s weird that it’s different from itself as well.
<FromGitter>
<johnjansen> yes predicatbility is essential
<Papierkorb>
those two behaving the same would make sense, yes
mooe has quit [Quit: Connection closed for inactivity]
<FromGitter>
<elorest> There might be a good reason they don’t but it seems weird to me
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
chimkan has quit [Quit: chimkan]
Nouv has quit [Quit: Nouv]
bjz has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
hightower has joined #crystal-lang
bjz has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]