leafybasil has quit [Remote host closed the connection]
canhtak has quit [Quit: canhtak]
a5i has quit [Quit: Connection closed for inactivity]
canhtak has joined #crystal-lang
Ven has quit [Ping timeout: 255 seconds]
Ven has joined #crystal-lang
<ytti>
jhass, does crystal has same property, that #match /foo/ is potentially ambiguous, and what would be lost, if it were not?
<jhass>
no idea actually
<jhass>
gotta wait till asterite drops in
<ytti>
(//) is so fugly
<jhass>
but he said once that he's against syntax warnings
<jhass>
either the parser should be smart about it or throw an error
<jhass>
like shadowing locals with block arguments, it was an error and we changed it to be allowed and not even warn
<jhass>
ruby warns on it
<ytti>
that really annoys me, let me dig my own grave
<ytti>
i know (sometimes) what i'm doing
<jhass>
yeah
<ytti>
need to come up with inconvenient variable names just to get rid of warning
<ytti>
especially in libraries which pass itself in block as argument
<ytti>
like net/ssh
<jhass>
yeah, it's why we removed the error
leafybasil has joined #crystal-lang
leafybasil has quit [Ping timeout: 245 seconds]
wanderer_ has joined #crystal-lang
canhtak has quit [Quit: canhtak]
<wanderer_>
jhass: just saw that this function `make_absolute_and_expand` is unnecessary in its whole, because `File.expand_path` prepends the working directory if the passed path isn't absolute
canhtak has joined #crystal-lang
<jhass>
nice catch
<wanderer_>
haven't tested it yet, but replacing `make_absolute_and_expand` directly with File.expand_path should work if I'm not mistaken, I'm atm having problems with it on windows as it's not expanding ".."
a5i has joined #crystal-lang
<wanderer_>
jhass: btw why is expand_path actually implemented, doesn't a call to LibC.realpath on unix suffice?
<jhass>
>> File.expand_path("~/a")
<DeBot>
jhass: "/home/crystal/a"
<jhass>
>> LibC.realpath("~/a")
<DeBot>
jhass: Error in line 3: wrong number of arguments for 'LibC#realpath' (1 for 2)
<jhass>
heh
<jhass>
anyway, it does more
<jhass>
also iirc realpath is FS bound
<wanderer_>
>> a :: UInt8[260]; LibC.realpath("~/a", a.buffer); String.new(a.buffer)
<DeBot>
wanderer_: "/home/crystal/~"
<jhass>
oO
<jhass>
that's some weird output
<jhass>
oh, right, realtive to pwd
<wanderer_>
it doesn't seem to understand ~, but only . and ..
<jhass>
yeah, and strips a since it doesn't exist
<jhass>
>> File.expand_path "~root"
<DeBot>
jhass: "/home/crystal/~root"
<jhass>
heh, so that's missing :
<jhass>
:P
<wanderer_>
maybe it'd work to replace a possible ~ and then just use realpath()?
<wanderer_>
then again I don't know how linux paths work
<jhass>
>> File.expand_path "/home/../nope"
<DeBot>
jhass: "/nope"
<jhass>
>> LibC.realpath "/home/../nope", out path; String.new(path)
<DeBot>
jhass: Error in line 3: wrong number of arguments for 'String#new' (1 for 0)
<wanderer_>
>> a :: UInt8[260]; LibC.realpath("/home/../nope", a.buffer); String.new(a.buffer)
<DeBot>
wanderer_: "/nope"
<jhass>
oh, mh
<jhass>
anyway, probably not worth it
<wanderer_>
well, it's already implemented and seems to work, was just wondering why the duplicate work
<jhass>
>> File.expand_path "a/../b", "/tmp/bar"
<DeBot>
jhass: "/tmp/bar/b"
<wanderer_>
I've read that on linux there's no general way to get the path of the executable? how does gcc for example finds its include files? "../include/" wouldn't work if the working directory is not gcc's folder, would it?
<jhass>
gcc has a built in search path afaik
<jhass>
there's probably some variable to set it too
<wanderer_>
and crystal finds its stdlib via a shell script when it's started from some other working directory?
<jhass>
both
<jhass>
it too has a compiled in default
<jhass>
set via CRYSTAL_CONFIG_PATH during compile time
<jhass>
and that default can be overridden (not amended) with CRYSTAL_PATH
<jhass>
I'm still trying to convince asterite to let CRYSTAL_PATH amend the default and have a -I CLI flag I guess
<wanderer_>
-I isn't implemented yet?
<jhass>
don't think so
<wanderer_>
the normal way is one default path and addable ones via -I, I guess
<jhass>
the three stage model is common and useful
<jhass>
ruby has it too
<wanderer_>
ah, k
<jhass>
1) default to work in unconfigured environment (compiled in default) 2) override/amend defaults in configured environment (environment variable) 3) override/amend configured environment on invocation
<wanderer_>
On Windows you'd simply retrieve the path the executable is in right now
canhtak has quit [Quit: canhtak]
<jhass>
yes, since windows follows an appdir approach, not something like the FHS
<jhass>
you can find appdir distros on linux too, I think gobolinux was one for example
<jhass>
OS X actually does a mixture
<jhass>
it has the FHS for posix compliance but actually installs apps into appdirs
<jhass>
but I think the 3 stage model is a lot more flexible, even if you'd guaranteed to be installed to an appdir
<wanderer_>
ah, yes, linux mostly has its executables in /bin/, docs in /share/, etco
<wanderer_>
etc.*
<jhass>
you would just choose a different (or additional) default for 1) when left unspecified during compile time I guess
Ponder has joined #crystal-lang
<Ponder>
Hi
<jhass>
hey
<Ponder>
I know Crystal is fast as it is now, but how much faster will it get over the releases?
<jhass>
probably not too significantly, the compiler speed is already pretty optimized and the executable speeds we get via LLVMs optimizations
<jhass>
maybe a different GC someday will make a difference
<jhass>
do you have a feeling that there's still much room for improvement?
<Ponder>
Well, being in it's pre-alpha stages at version 0.6.1, yes
<jhass>
so no actual code you have that runs slow :)
<Ponder>
How different would Crystal be without a GC, and isnt it optional?
leafybasil has joined #crystal-lang
<jhass>
and actually we're officially in alpha as of yesterday :D
<Ponder>
:O
<jhass>
the GC is not easily taken out (at least yet)
<jhass>
the alpha stage mostly refers to language bugs and language design
<Ponder>
I thought if you set prelude to empty, it wouldnt initalize it
<jhass>
crystal generates LLVM IR, so that side is pretty much as good as it gets already I said
<jhass>
*I'd say
<Ponder>
I see
<jhass>
mh, I never tried
<Ponder>
ping dom96
<jhass>
but I wouldn't even know how to free an object :P
asterite has joined #crystal-lang
<dom96>
Ponder: hi, what's up?
<Ponder>
dom96 arent you from Nim?
<asterite>
Ponder: most of the optimizations right now are done by LLVM, but we can still do our own optimizations. For example escape analysis
<dom96>
indeed
canhtak has joined #crystal-lang
<asterite>
Or, as jhass said, use a specialized GC. There's still room for improvement
<jhass>
I just wouldn't say it's a pressing issue, it's pretty decent already
<Ponder>
asterite, that sounds great, Do you know when the next release of Crystal is?
<asterite>
jhass: exactly. Even Go is slower than Crystal in many aspects but it's already decent so I think they say "It' ok like that, let's focus on other things"
<Ponder>
I heard it would include non-blocking IO and lightweight processes
<asterite>
Ponder: Yes, that's already on HEAD
<a5i>
asterite: I still cant compile HEAD :(
<asterite>
because of the memory issue?
<a5i>
asterite: No, outdated verion of libpcl
<asterite>
Ah... we'll include a compatible one in the next release. I guess right now you won't be able to try it :(
<a5i>
thank god, when is the next release if you may say?
<asterite>
After at least two weeks
<dom96>
Ponder: why do you ask?
<Ponder>
dom96, I swear I've seen you there
<Ponder>
I don't remember though
<asterite>
I rememebr dom96 is pretty active on the Nim forums
<asterite>
(I read them frequently)
<dom96>
Ponder: Yeah, i'm one of the main devs.
<Ponder>
dom96, knew it :)
<a5i>
You guys over at nim have this guy who totally hates Rust
<jhass>
asterite: are you going to fix IO.select first or do I have to start crystal-posix-io? :P
<asterite>
We'll fix it. Or, better said, waj will probably fix it :-P
Ponder has quit [Quit: Page closed]
<dom96>
a5i: who are you referring to?
<asterite>
Or... maybe we won't have IO.select and you'll have to use Channel.select or something like that. We still don't know, waj has a more clear overall picture
* jhass
creates repo...
<asterite>
jhass: no, no, there's still time for discussion! :-P
asterite has quit [Quit: Page closed]
<jhass>
and then he drops out...
<a5i>
dom96: Jason Livesay?
<dom96>
a5i: I haven't seen him since he posted that one rather rude thread.
<a5i>
dom96: That's good, and yeah agreed on the latter xP
weskinner_work has joined #crystal-lang
weskinner_work has quit [Ping timeout: 265 seconds]
<wanderer_>
when compiling spec/compiler/compiler_spec.cr and the `require "../src/compiler/crystal/**"` is encountered, then fullname seems to be equal to for example "/home/ubuntu/crystal/spec/../src/compiler/crystal//command.cr"
<wanderer_>
however, printing `result` in find, line 12, it contains "/home/ubuntu/crystal/src/compiler/crystal/command.cr" instead
<wanderer_>
oh.. I totally overlooked the `files_accumulator << File.expand_path(file)`...
<jhass>
happy rubberducking!
<wanderer_>
that's what I was actually looking for, don't know how I could not see that
<jhass>
yw
<wanderer_>
thanks :P
<jhass>
IRC, Interactive Rubber duCK :P
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven has joined #crystal-lang
sandelius has joined #crystal-lang
canhtak has quit [Quit: canhtak]
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<wanderer_>
jhass: PROGRAM_NAME isn't reliable on linux then, is it?
Ven has joined #crystal-lang
<jhass>
how so?
<jhass>
well, it may be a symlink I guess
<jhass>
>> PROGRAM_NAME
<DeBot>
jhass: "/tmp/crystal-run-eval.AdIwf1"
<wanderer_>
1. it could be a full path or just a single filename 2. I've read that its correctness depends on the caller
<wanderer_>
and that it's just a convention
<wanderer_>
not a requirement
havenwood has joined #crystal-lang
<jhass>
eh, well, I guess so
<wanderer_>
jhass: when is code like `STDIN = CFileIO.new(LibC.stdin)` and `ARGV = (ARGV_UNSAFE + 1).to_slice(ARGC_UNSAFE - 1).map { |c_str| String.new(c_str) }` actually executed, what is its scope and can local variables be used there or "out xxx"?
<jhass>
I'm not sure I quite follow
<jhass>
the lexical scope of constants is global
sandelius has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<jhass>
I'm not follow where you want to use an out parameter in one of those two expressions
<wanderer_>
in argv.cr I want to add `argv = LibWin32.wcommandlinetoargv(LibWin32.wgetcommandline, out argc); ARGV = Slice.new(argc - 1) { |i| String.new((argv + i + 1).value) }`
<jhass>
and that doesn't work?
<wanderer_>
I get "undefined local variable or method 'argc'"
<jhass>
mh
<jhass>
sounds like a bug to me
<jhass>
but interesting API, I'd expect the array to be an out parameter and the count to be returned
<jhass>
or let's say I'm used to that way around
a5i has quit [Quit: Connection closed for inactivity]
<wanderer_>
it's kind of a weird API function, it's one of few on windows that allocate the buffer themselves
<wanderer_>
is the commandline passed to the executable on unix always globbed?
<jhass>
"globbed"?
<wanderer_>
wildcards expanded
<wanderer_>
e.g. "*.*"
<jhass>
yeah, wildcards are a shell thing
<jhass>
they're expanded by the shell
<jhass>
and thus meant literal in argv
<wanderer_>
so what if you'd actually want to pass "*.*" itself to the program?
<jhass>
that depends on the shell, but quoting it usually works
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ponga has quit [Quit: Leaving...]
Ven has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<asterite>
In any case, having a global constant depend on a local variable seems weird to me
<jhass>
I think that would be awesome, at least having another error would be great though, like "Can't assign constant from local variable"
wanderer_ has joined #crystal-lang
<jhass>
I wouldn't say so, especially on the top level
<asterite>
Yes, the error message can be improved :)
<weskinner_work>
trying to figure out: "can't execute `(return {:none, :nil}) === __temp_172` at /home/william/play/ctf/src/main.cr:203:7: `return {:none, :nil}` has no type"
<jhass>
protip: Github has Crystal syntax highlighting! name your gist file something.cr
<weskinner_work>
daumn!!
<weskinner_work>
movin' on up!
asterite has quit [Ping timeout: 246 seconds]
<jhass>
mh, well, that snipped doesn't reproduce due to all the missing constants and stuff :/
<jhass>
what's line 203 though?
<jhass>
oh I see
<jhass>
you have an empty when clause on line 17
<jhass>
thus it parses as when(return ...)
<jhass>
and thus transforms to e.type === (return ...)
<jhass>
weskinner_work: ^
<jhass>
should probably a parse error though
<weskinner_work>
ahh!
<weskinner_work>
thanks
<jhass>
>> case 1; when return 2; end;
<DeBot>
jhass: Error in line 3: can't return from top level
<wanderer_>
jhass: so do constants get executed over and over again? are they like `#define`s?
<jhass>
wanderer_: no
<jhass>
it just means they're not typed if they're never accessed
<wanderer_>
just once, but lazily?
<jhass>
or probably not even generated
<jhass>
yeah
<jhass>
>> def foo; case 1; when return 2; end; end; foo
<DeBot>
jhass: can't execute `(return 2) === __temp_168` at eval:3:28: `return 2` has no type (Exception)
<jhass>
weskinner_work: ^ minimal code for your bug report ;)
<weskinner_work>
:)
<wanderer_>
so I need to put the winapi call inside of a begin-end-constant?
<jhass>
wanderer_: yeah
asterite has joined #crystal-lang
<wanderer_>
when my code looks like this `LibC.bla(out x); ABC = x.y` I refactor it to `ABC = begin; LibC.bla(out x); x.y; end;`
<wanderer_>
what about `LibC.bla(out x); ABC = x.y; XYZ = x.z;`?
<asterite>
For example if you don't use ARGV the program doesn't bother in creating an Array from argc/argv (but that's just a tiny fraction of the startup, so we might change the semantics to be more Ruby-like)
<asterite>
wanderer_: Right, seems it can't be done right now
<crystal-gh>
[crystal] asterite pushed 1 new commit to master: http://git.io/veYB7
<crystal-gh>
crystal/master d2f5751 Ary Borenszweig: Fixed more cases of "void value expression"
<asterite>
wanderer_: jhass: that fixes the "when return" thing
<jhass>
weskinner_work: ^
<asterite>
Ah, right :)
<jhass>
happens ;)
<weskinner_work>
asterite: ty
<wanderer_>
asterite: would something like `A = begin ... end; B = begin ... use A ... end; C = begin ... use A ... end;` work?
<asterite>
wanderer_: I think we can make it so that you can use local variables like in Ruby, I have to try
<asterite>
Oh, you can always do ARGV_FULL = ... and put all of argv contents there, and then do PROGRAM_NAME = ARGV_FULL[0]; ARGV = ARGV_FULL[1 .. -1]
<asterite>
Some extra memory allocations and slices, but it should work for now, until we change constants semantics
<asterite>
Or you can use $global_variables for argc and argv, constants can access them. All of these solutions are ugly but should work for now
<travis-ci>
manastech/crystal#2180 (master - d2f5751 : Ary Borenszweig): The build was fixed.
<jhass>
ARGC, ARGV = begin; ...; {argc, argv}; end; won't work I guess?
<wanderer_>
no, I've already tried that
<wanderer_>
but putting everything in a constant and using that one is ok
<asterite>
wanderer_: what was the problem with windows and generate_docs?
<wanderer_>
btw. got some general question: 1. what's exactly a tuple and what is the difference between a tuple, a slice and an array? 2. what about a `String#[]?`?
<asterite>
wanderer_: I'll hopefully document these soon, I'm slowly documenting the basic types
<asterite>
A tuple is immutable, allocated on the stack and passed by value, so it's like a struct with N members that you can access with numbers instead of names
<asterite>
and a Slice is just a struct that has a pointer and an associated length
<wanderer_>
so a Slice is a part of an Array?
<wanderer_>
and a Tuple is a stack array
<asterite>
You can think Array is built on top of Slice (but instead it uses pointer and does its own bound checks, maybe because Slice didn't exist back then)
<asterite>
A Tuple can't grow or shrink, nor it can be changed, so it's not like a stack array
<wanderer_>
yeah, static stack array
<wanderer_>
array = contiguous memory
<asterite>
Ah, yes :)
<wanderer_>
tuple syntax is {} ?
<asterite>
Yes, {1, 2, 3}
<asterite>
wanderer_: what was the issue with generate_docs on windows?
<wanderer_>
try it yourself
<wanderer_>
uncomment the line and compile the compiler