NeverDie has quit [Quit: I'm off to sleep. ZZZzzz…]
sailorsw_ has joined #crystal-lang
sailorsw_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
miah has quit [Ping timeout: 264 seconds]
miah has joined #crystal-lang
havenwood has joined #crystal-lang
havenwood has quit [Remote host closed the connection]
ddfreyne has quit [Ping timeout: 252 seconds]
havenwood has joined #crystal-lang
eam has quit [Ping timeout: 250 seconds]
eam has joined #crystal-lang
elbow has quit [Ping timeout: 272 seconds]
ddfreyne has joined #crystal-lang
elbow has joined #crystal-lang
sailorswift has joined #crystal-lang
havenwood has quit [Ping timeout: 250 seconds]
BlaXpirit has joined #crystal-lang
sailorswift has quit [Read error: Connection reset by peer]
sailorswift has joined #crystal-lang
<strcmp1>
you can tell two threads got together to spell that filename
<jhass>
dzv: to elaborate on why your example doesn't work: parallel is a macro, as such its parameters are interpreted as code, if you pass a variable you pass code referencing a variable, not what the variable points to. Think of it as a template and the parameter gets literally inserted into it
strcmp1 has quit [Quit: Leaving]
<dzv>
is it possible to have a dynamic array of things and pass it to parallel?
kyrylo has joined #crystal-lang
<kyrylo>
Hi! Does anyone know if there's crystal-mode for Emacs?
nahtnam has quit [Quit: Connection closed for inactivity]
<kyrylo>
When I `raise` an exception, is it possible to extract filenames from the exception's backtrace? It looks like Crystal doesn't provide such information
sailorswift has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<jhass>
no, I guess mainly because we don't generate LLVM 3.6 compatible debug info
<kyrylo>
Aww
<jhass>
asterite: http://carc.in/#/r/aau nobody opened an issue for this, so I will unless I'm missing the stack overflow somewhere?
<kyrylo>
consider this frame "main +108 [0]" What does the [0] part mean?
leafybasil has quit [Remote host closed the connection]
<kyrylo>
Thanks. It looks like it's a pointer address, isn't it? "fname" probably means filename, but it doesn't look like a filename and "offset" is a line number
<jhass>
unw_get_proc_name -- get name of current procedure
<jhass>
so more function name
<jhass>
and I guess IP instruction pointer, pc program counter (which is the same thing)
<kyrylo>
"functionName" then I guess
<kyrylo>
ah
<kyrylo>
right
<kyrylo>
:)
NeverDie has quit [Quit: I'm off to sleep. ZZZzzz…]
maxdeviant has joined #crystal-lang
<maxdeviant>
Having a bit of trouble getting some JSON data into a usable format. I'm doing `JSON.parse(File.read("../path/to/file"))`, but I'm not sure how to get it into a usable format from there
<maxdeviant>
(Trying to do a key lookup, which I expected would be something like `json_data["key"]`, but all I get is `undefined method '[]' for Nil (compile-time type is (Nil | String | Int64 | Float64 | Bool | Hash(String, JSON::Type) | Array(JSON::Type)))`
<BlaXpirit>
maxdeviant, json could be anything
<BlaXpirit>
for example, the whole json document could consist of just "null"
<jhass>
maxdeviant: try json_mapping if your data is somewhat structured
<jhass>
nopc0de: is that the debian curl?
<nopc0de>
default osx curl
<jhass>
ah, so nothing I can try
<jhass>
you're sure you use the head compiler? what does command_you_use_to_compile_the_example -v say?
<jhass>
?json_union maxdeviant
<nopc0de>
Crystal 0.7.5 [4288b21] (Fri Aug 7 22:11:15 UTC 2015)
* jhass
slaps DeBot
<jhass>
mmh, weird
<maxdeviant>
jhass, trying to figure out how I would use either of those. json_mapping sort of makes sense to me, but I'm unsure how I would use the macro
<maxdeviant>
jhass: Derp, my GitHub was pointing at an old revision of that file. One without any comments
<maxdeviant>
jhass, alright, look's like it's working. Thanks for your help!
<maxdeviant>
Next time I'll make sure that I'm on the master branch, cause that probably would have answered my questions :P
<jhass>
no worries, yw :
havenwood has joined #crystal-lang
elia has joined #crystal-lang
oal has quit [Remote host closed the connection]
elia has quit [Quit: Computer has gone to sleep.]
elia has joined #crystal-lang
elia has quit [Client Quit]
leafybasil has joined #crystal-lang
<asterite>
jhass: about that carc.in example with array :: Array(Int32), that makes array have garbage, a segmentation fault is what will happen in %99.9 of the cases
<jhass>
asterite: but I mean it's nowhere used? def get(..., *handlers
<asterite>
Ah, let me check
leafybasil has quit [Ping timeout: 250 seconds]
<asterite>
seems like a stack overflow, the "next" of the handler points to itself?
<asterite>
`handler.next = handler`
<jhass>
ah, that makes sense
<asterite>
we should definitely make something about stack overflows. I'll add it to the roadmap so it can't go away :-)
<jhass>
good
<jhass>
I agree that we also should do something about usable backtraces btw
<jhass>
but I guess that mandates llvm 3.6 (or 3.7) debug info first
<asterite>
Yes
leafybasil has joined #crystal-lang
<jhass>
asterite: that's a bit sad about Errno, it means 99% of the proper code catching Errno will look at .errno and reraise and 80% of code catching Errno at all will swallow unexpected cases
<kyrylo>
Sorry, seems like the JSON module cannot "generate" JSON, can it?
<jhass>
sure it can
<jhass>
>> {"foo": "bar"}.to_json
<DeBot>
jhass: Error in line 4: undefined method 'to_json' for Hash(String, String) - http://carc.in/#/r/ajv
<asterite>
Maybe EMLINK too, in the above (I don't even know when those happen)
<jhass>
but that's useful information already
<jhass>
ENFILE, I probably can't recover, the system is overloaded
<asterite>
The thing is, when you have an operation, you don't expect all of Errno error codes, just some. Then you classify those into exceptions you already have (or create), and I bet you'll end up with a smaller hierarchy
<jhass>
with EMFILE I can see if I can close some files
<jhass>
I mean the kernel devs aren't stupid, they won't introduce new error codes if they don't provide a useful distinction from some other error code
<jhass>
in fact I already often wished for even more specific codes
<jhass>
for example you get EPERM for all sorts of stuff
<asterite>
For example, take a look at java's FileInputStream
<asterite>
When you create one, possible exceptions are FileNotFoundException and SystemSecurityException
<jhass>
yeah, that throws a generic IOError "something went wrong"
<asterite>
Um, SecurityException
<asterite>
while libc's open has like 20 different ERRNOs
<asterite>
But I know ruby is closer to unix in this sense and allows you to go deeper than java (maybe because java tries to abstract all of that)
<asterite>
I really have to discuss this with waj, or we can continue the discussion in #445
<jhass>
Whether I couldn't open the file because it's actually a directory or because I can't read it is very useful option
<jhass>
*information
<jhass>
it allows to generate actually useful error messages to the user
<jhass>
instead of a generic "couldn't open it"
<jhass>
or relying on the exception message and displaying that to the user (bye nice i18n)
<jhass>
or doing all the checks the OS already does for me in advance
<asterite>
Yes, but the current Errno exception gives you that information. Creating a specific errno class, always, regardless of whether the user actually wants to know that much, bloating the binary and slowing down the compiler seems like a bad thing to do
<asterite>
Another answer for the above could also be: if we can make the compiler faster in this sense, we might consider changing this
<asterite>
:-)
<jhass>
I guess the compromise could be to have more generic error classes but have methods on them to determine the specific error
<asterite>
Yes, that's another alternative
<asterite>
Got to go, bye!
<jhass>
rescue e : FileAccessError; case e.reason; when :is_directory; when :permission_denied
elia has joined #crystal-lang
NeverDie has joined #crystal-lang
NeverDie has quit [Client Quit]
elia has quit [Quit: Computer has gone to sleep.]
elia has joined #crystal-lang
NeverDie has joined #crystal-lang
<kyrylo>
What are the alternatives for RUBY_PLATFORM and RUBY_VERSION in Crystal?
<elbow>
So are these Fiber's in fact multithreaded? or are they simply co-routines?
<jhass>
they are coroutines (based on libpcl atm), but there are plans for a multithreaded work stealing scheduler
<elbow>
jhass: oh cool. thanks for the help! :)
kyrylo has quit [Ping timeout: 255 seconds]
NeverDie has quit [Quit: I'm off to sleep. ZZZzzz…]
sailorswift has joined #crystal-lang
<elbow>
I have officially spent at least an hour trying to align the 3d shape on the crystal-lang webpage so that it is an exact replica of the logo.
<jhass>
xD I guess we need a keyboard shortcut :P
<elbow>
hacks!
<elbow>
that would be quite fun
blue_deref has quit [Quit: bbn]
leafybasil has quit [Remote host closed the connection]
leafybasil has joined #crystal-lang
leafybasil has quit [Ping timeout: 240 seconds]
leafybasil has joined #crystal-lang
blue_deref has joined #crystal-lang
kyrylo has joined #crystal-lang
blue_deref has quit [Quit: bbn]
leafybasil has quit [Read error: Connection reset by peer]
leafybasil has joined #crystal-lang
<dbackeus>
kyrylo: thanks for the airbrake package
<dbackeus>
did you consider using a client instance instead of class level singleton?
<dbackeus>
I feel like the singleton approach is an anti pattern that got way to popular in ruby
<dbackeus>
yes - it's often unlikely to need two use two different api accounts in a single app, but it can happen, more for some API's than others, and now might be the time to set good idioms and example for the crystal developers to come :)
<kyrylo>
dbackeus, you are welcome! I did :) Luckily, it's not hard to change.
<kyrylo>
dbackeus, do you have a realistic scenario for that, though?
<kyrylo>
dbackeus, the library doesn't offer many features at the moment, but in the future it will have all the standard stuff like logging, asyncness, etc
<kyrylo>
dbackeus, I don't mind the per-instance design, but I'm curious if it's *really* needed :)
<dbackeus>
for Airbrake specifically - you might use different airbrake buckets for different part of the app, for example one for the web and one for background jobs
<dbackeus>
say we figure out an awesome way to run background jobs in the same Crystal process
<dbackeus>
and your library doesn't work any more :(
<dbackeus>
I once wrote an API wrapper for my own web app with this style, since it is a lovely API and all... later on I dog fooded it for one of our projects and I needed to use it for multiple accounts and realized I could never have thread safety with the singleton approach
<dbackeus>
lessons learned
<kyrylo>
Haha, yeah. Thanks for the feedback! I think I'll change that now :)
<dbackeus>
AIRBRAKE = Airbrake.new(project_id: "xxx", project_key: "xxx") would be a way to get a system wide instance if wanted
<dbackeus>
if you're really fond of the clean api you could possibly support both
<kyrylo>
That would be an overkill, I think
<dbackeus>
Airbrake.configure would configure the default singleton instance - which in turn would be just an instance of Airbrake.new
<kyrylo>
Ah, I see
<kyrylo>
That's interesting
<kyrylo>
Makes sense
<kyrylo>
So you don't have to do anything to have a global isntance
<dbackeus>
exactly, but where you wanted instances you could simply do Airbrake.new, and since you would any way use the instance for the singleton you wouldn't have to do any crazy code to make it work
<kyrylo>
Yeah, that sounds very cool
<dbackeus>
ok, GLHF :)
<dbackeus>
good night!
<kyrylo>
Thanks :)
<kyrylo>
Nighty night
dbackeus has quit []
trapped has quit [Ping timeout: 246 seconds]
elia has joined #crystal-lang
blue_deref has joined #crystal-lang
BlaXpirit has quit [Ping timeout: 246 seconds]
BlaXpirit has joined #crystal-lang
BlaXpirit has quit [Read error: Connection reset by peer]
BlaXpirit has joined #crystal-lang
elia has quit [Read error: Connection reset by peer]
elia_ has joined #crystal-lang
NeverDie has joined #crystal-lang
elia_ has quit [Quit: Computer has gone to sleep.]
kyrylo has quit [Quit: Konversation terminated!]
sfcgeorg_ has joined #crystal-lang
sfcgeorge has quit [Killed (hobana.freenode.net (Nickname regained by services))]
sfcgeorg_ is now known as sfcgeorge
<dzv>
is there a way to specify which libgc is used? mine is installed in a nonstandard path
<BlaXpirit>
dzv, normal linker is used
<BlaXpirit>
u can specify paths in which it will look for libraries
<BlaXpirit>
but it's gonna be a pain for you all the way through
<BlaXpirit>
because u also need to specify that path when executing your program
<BlaXpirit>
on linux i can do LD_LIBRARY_PATH=/path/ crystal blah
<dzv>
there is no provision for adding -L/path as part of building crystal itself and all programs with it?