<crystal-gh>
[crystal] yui-knk opened pull request #893: Add test for Char#to_i raise Exception (master...test/char_to_i) http://git.io/vtEcS
waj has quit [Quit: waj]
wanderer_ has quit [Quit: Page closed]
havenwood has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<ozra_>
Very micro-opty question here, but: For long case .. when .. - does it benefit to put most commonly hit cases earlier? Or how is it implemented under the hood?
datanoise has joined #crystal-lang
fowlduck has joined #crystal-lang
datanoise has quit [Ping timeout: 256 seconds]
fowlduck has quit [Ping timeout: 244 seconds]
<willl>
the llvm-ir that is generated appears to go in order, what llvm does with that afterwards i don't know
<jhass>
vifino: yeah, we'll need to separate it at some point but for now it's easier on one repo, until shards is ready at least
<jhass>
so PRs welcome!
<jhass>
willl: ozra left but iirc case when is actually just a syntax rewrite to some if/elsif construct
fowlduck has joined #crystal-lang
fowlduck has quit [Ping timeout: 248 seconds]
BlaXpirit has joined #crystal-lang
ashleyis has joined #crystal-lang
datanoise has quit [Ping timeout: 256 seconds]
datanoise has joined #crystal-lang
NeverDie has quit [Read error: Connection reset by peer]
NeverDie has joined #crystal-lang
bcardiff has quit [Quit: Leaving.]
unshadow has joined #crystal-lang
datanoise has quit [Ping timeout: 256 seconds]
fowlduck has joined #crystal-lang
fowlduck has quit [Ping timeout: 248 seconds]
Ven has joined #crystal-lang
fowlduck has joined #crystal-lang
fowlduck has quit [Remote host closed the connection]
unshadow has quit [Quit: leaving]
strcmp1 has quit [Quit: Leaving]
NeverDie has quit [Quit: I'm off to sleep. ZZZzzz…]
genixefr has quit [Ping timeout: 246 seconds]
genixefr has joined #crystal-lang
fowlduck has joined #crystal-lang
datanoise has joined #crystal-lang
fowlduck has quit [Ping timeout: 248 seconds]
ozra_ has joined #crystal-lang
datanoise has quit [Ping timeout: 246 seconds]
<ozra_>
I get this error when compiling with the freshly built compiler - but not when compiling with the centrally installed. Anyone? Wrong versions of libs? https://gist.github.com/ozra/8c60b18fc56ecc68abf8
<jhass>
mmh, sounds like too old libpcl and gc version to me
<jhass>
btw re. case/when, that's just transformed to a if/elsif chain
<jhass>
so the answer is yes, putting the common case at the top saves you a bunch comparisons
<ozra_>
jhass: Ok, cool! Why does the compiler compile with the central compiler (wheew - that sentence ;-)
<jhass>
because the official package ships with newer versions of the library and munges LD_LIBRARY_PATH so it can find them
<jhass>
so I guess if you look at the wrapper of the package you could reuse them
<ozra_>
Aha, thanks. I saw some in /opt/crystal/embedded/lib/ - must be them then.
<jhass>
yeah
<ozra_>
jhass: Does most crystal developers use Mac?
<jhass>
waj & asterite do if that's what you mean
<ozra_>
jhass: Ok, I saw a Mac specific if-branch in the Makefile that seemingly would take care of this problem. Hmm, still trying to figure out how to get crystal to use my -Lpath... Or perhaps it's rather cc that prefer the global over the specified.
<ozra_>
No, cc doesn't get the --link-flags?? Not in the error message it hasn't anyway :-/
<ozra_>
Do you know if this is correct?: "CRYSTAL_CONFIG_PATH=`pwd`/src ./bin/crystal build --link-flags '-L/opt/crystal/embedded/lib' -o .build/crystal src/compiler/crystal.cr"
<ozra_>
Ok, it seems, when passing -L... to the failing 'cc ...' and executing manually, it works. But the make is aborted due to this one. So it seems like the --link-flags are not passed to all linkings from crystal
daneb has joined #crystal-lang
daneb has quit [Remote host closed the connection]
daneb has joined #crystal-lang
havenwood has joined #crystal-lang
fowlduck has joined #crystal-lang
fowlduck has quit [Ping timeout: 248 seconds]
daneb has quit [Remote host closed the connection]
daneb has joined #crystal-lang
daneb has quit [Remote host closed the connection]
daneb has joined #crystal-lang
daneb has quit [Remote host closed the connection]
daneb has joined #crystal-lang
bcardiff has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
daneb has quit [Remote host closed the connection]
daneb has joined #crystal-lang
daneb has quit [Remote host closed the connection]
daneb has joined #crystal-lang
<daneb>
hi Gentleman and Ladies
unshadow has quit [Quit: leaving]
<daneb>
is there a consideration around threading best practice for Crystal? (as in will there be something baked into the language itself). Kind of like Go and Elixir with the Actor Pattern
<daneb>
or documentation I maybe missed on the issue
daneb has quit [Remote host closed the connection]
fowlduck has joined #crystal-lang
datanoise has joined #crystal-lang
fowlduck has quit [Ping timeout: 248 seconds]
datanoise has quit [Client Quit]
Ven has joined #crystal-lang
unshadow has joined #crystal-lang
<unshadow>
While reading a socket I need to do this: "buf :: UInt8[1024]" , this will be used as a buffer to read into the incoming data, when I try to use this inside a method like this "buf :: UInt8[to_read]" where I pass the number of bytes as a veriable I get " expecting token 'CONST', not 'to_read'" Is this a bug ? am I missing something ?
<vifino>
jhass: Seems like a plan. I've been getting weird errors trying to build parts of it, I'll poke you on that later :) It's related to the G lib wrapper, something like LibGLib::Error is not defined.
<unshadow>
jhass: maybe you can answer, is there another way to create this: "buf :: UInt8[10]" I know it creates "StaticArray(UInt8, 10)", can I create this Array using StaticArray(UInt8, 10).new or something ? because I keep getting errors
<travis-ci>
manastech/crystal#cd09304 (master - Merge pull request #894 from yui-knk/fix/expect_raises_2
<unshadow>
Ok... what am I doing wrong ?? This looks exactly like in the API page http://carc.in/#/r/5ui
<BlaXpirit>
unshadow, length must be known at compile time
<unshadow>
BlaXpirit: where does buf :: UInt8[1024] takes the data from ? (as in the value : T)
<BlaXpirit>
unshadow, this is unsafe. the data is trash, whatever was in RAM
<unshadow>
BlaXpirit: ohhhh ok, I see
<unshadow>
then it's better to specify a value right ? this way it makes it "safe" again ?
<BlaXpirit>
i'm not sure about what i said
<BlaXpirit>
in this case I don't think anything bad can happen, just that it's uninitialized
<BlaXpirit>
if you pass this to some function that will fill the buffer, this is a perfeclty fine use case
BlaXpirit has quit [Quit: Quit Konversation]
<unshadow>
BlaXpirit: ok, then another question if you will, the first one I asked: While reading a socket I need to do this: "buf :: UInt8[1024]" , this will be used as a buffer to read into the incoming data, when I try to use this inside a method like this "buf :: UInt8[to_read]" where I pass the number of bytes as a veriable I get " expecting token 'CONST', not 'to_read'" Is this a bug ? am I missing som
<unshadow>
ething ?
<unshadow>
btw, the method takes (to_read : Int32) so there is now way to have something other then int there
BlaXpirit has joined #crystal-lang
fowlduck has joined #crystal-lang
<BlaXpirit>
<BlaXpirit> unshadow, length must be known at compile time
<BlaXpirit>
please tell me what you're trying to use like that
<BlaXpirit>
which socket, where is its documentation
fowlduck has quit [Ping timeout: 264 seconds]
<unshadow>
BlaXpirit: ok, I understand now that you said that about my question. Here is what I'm trying to acomplish --> http://carc.in/#/r/5up
<BlaXpirit>
unshadow, loop + string builder is the only option I see
<BlaXpirit>
or maybe there is some kind of dynamic array
<BlaXpirit>
maybe you can use non-static array
<BlaXpirit>
>> Array(UInt8).new(50).to_slice
<DeBot>
BlaXpirit: Error in line 4: undefined method 'to_slice' for Array(UInt8) - http://carc.in/#/r/5uq
<BlaXpirit>
>> UInt8[50].new.to_slice
<DeBot>
BlaXpirit: Error in line 4: undefined method 'new' for Array(UInt8) - http://carc.in/#/r/5ur
<BlaXpirit>
i dont know
Kilobyte22 has joined #crystal-lang
<unshadow>
>> a = [] of UInt8; 50.times do { a << 8u8 } end ; puts a.to_slice
<DeBot>
unshadow: Error in line 4: undefined method 'to_slice' for Array(UInt8) - http://carc.in/#/r/5us
<unshadow>
>> a = [] of UInt8; 50.times do { a << 8u8 } end ; puts a
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
asterite has joined #crystal-lang
<asterite>
unshadow: in StaticArray, the "static" means the length is known at compile time
asterite has quit [Client Quit]
<vifino>
Hey BlaXpirit - Your crystalize.py thingie is always stuck: pycparser.plyparser.ParseError: /usr/include/stdarg.h:34: Directives not supported yet
<BlaXpirit>
vifino, give me more details so i can fix it
<vifino>
BlaXpirit: ./crystalize.py /usr/include/luajit-2.1/lua.h delivers the above; ./crystalize.py /usr/include/stdio.h delivers: │pycparser.plyparser.ParseError: /usr/include/features.h:97: Directives not supported yet
ashleyis has quit [Ping timeout: 256 seconds]
fowlduck has joined #crystal-lang
<BlaXpirit>
vifino, well it's not supposed to parse nonstandard headers
<BlaXpirit>
vifino, i have luajit 2.0 and it parsed
<vifino>
BlaXpirit: It hasn't parsed any header at all yet.
<BlaXpirit>
vifino, did you install pycparser or use the provided submodule
fowlduck has quit [Ping timeout: 248 seconds]
<vifino>
BlaXpirit: I had pycparser already installed..
<BlaXpirit>
well there's the problem
<BlaXpirit>
pycparser python module is not the only thing that's needed
<BlaXpirit>
the headers bundled with it are important
<vifino>
But then it fails with ImportError: No module named 'pycparser.c_generator' :v
<BlaXpirit>
vifino, works here with 2.1 too
<BlaXpirit>
you must have the pycparser folder, so clone --recursive
<ozra_>
Where can I read more about getter, setter, property, etc. I can't seem to find it in the docs?
<jhass>
vifino: that might be, crystal does stuff lazy and does most checks only if you actually call stuff, so just because all the generated stuff can be required it's not semantically correct
<jhass>
unshadow: I think you generally want to use the Slice API to read stuff into buffers, it's a lot safer
<Kilo`byte>
can anyone explain me why this line is throwing 'missing separator': .PHONY spec
<waj>
should be: .PHONY: spec
<Kilo`byte>
ah okay
NeverDie has joined #crystal-lang
fowlduck has joined #crystal-lang
fowlduck has quit [Ping timeout: 248 seconds]
<Kilo`byte>
what am i doing wrong? i converted a union to an array (in this context i can be sure the type is correct). then i map the elements of said array and finally splat it. i get this error: "splatting a union (Array(String)) is not yet supported"
<Kilo`byte>
at that point data seems to be (Array(String)) and not Array(String)
<daneb>
asterite 22 days ago
<daneb>
I think Crystal could fit this bill, yes: it has Ruby syntax and the concurrency model will be something like Go (spawn and channels, but we are still working on this). And the code ends up without much repetition, as you have generics, macros, very few type annotations, and things like sort, map, select, inject, etc.
<daneb>
ah, found my answer:
<daneb>
;)
blue_deref has quit [Quit: bbn]
<Kilo`byte>
somehow everyone who usually is so helpful has suddenly gone missing
<vifino>
Kilo`byte: I have no idea, sadly, so I won't be of much help :(
<BlaXpirit>
Kilo`byte, by "everyone" you mean jhаss?
daneb has quit [Remote host closed the connection]
<BlaXpirit>
Kilo`byte, i dont know why your code doesnt work but i know what you should do instead
daneb has joined #crystal-lang
<BlaXpirit>
actually i do know
<BlaXpirit>
Kilo`byte, splatting an array as function arguments is invalid
<Kilo`byte>
okay
<BlaXpirit>
>> puts(*["1", "2", "3"])
<DeBot>
BlaXpirit: Error in line 4: splatting a union (Array(String)) is not yet supported - http://carc.in/#/r/5va
<Kilo`byte>
well, i do not know the param count at runtime
<Kilo`byte>
err compile time
<BlaXpirit>
so how can you call a function without knowing the param count?
<BlaXpirit>
that's invalid
<BlaXpirit>
maybe it's possible to make, hence not "yet" supported
<Kilo`byte>
well, i am still used to ruby where that is possible
<Kilo`byte>
now i gotta find a workaround...
<BlaXpirit>
what do you really want
<BlaXpirit>
print everything joined by space?
<Kilo`byte>
nah
<Kilo`byte>
that was just a very simple example
daneb has quit [Ping timeout: 246 seconds]
daneb has joined #crystal-lang
<jhass>
BlaXpirit: what a weird a
havenwood has joined #crystal-lang
<jhass>
Kilo`byte: simply define your method to take an enumerable, and define an overload of def foo(*bars); foo(bars); end; if you want to support a nicer calling syntax too
<Kilo`byte>
jhass: hmm i can do that
<Kilo`byte>
is a StaticArray allocated on heap or stack
<Kilo`byte>
so i'd probably need a regular array/pointer combo
<jhass>
Slice should do
<jhass>
if you need it heap allocated
<Kilo`byte>
basicly i need something that i can create a pointer of and shove it into c code
<jhass>
while it's pass by value for its data structures, it points to heap memory
<Kilo`byte>
i need a pointer to it anyways
<Kilo`byte>
:P
<jhass>
whatcha get out? a string?
<Kilo`byte>
i have a blackbox pointer basicly (c side its a complex struct and i really don't want to reimplement the entire struct as it consists of numerous sub structs
<Kilo`byte>
and i don't need to access any values inside of it
waj has quit [Ping timeout: 250 seconds]
<jhass>
but you have to allocate the memory for it yourself?
<Kilo`byte>
yes
<Kilo`byte>
to init it i pass a pointer to the allocated struct to a init function
<jhass>
one approach is to just do something like lib LibFoo; struct Bar; _data : UInt8[size]; end; end;
<Kilo`byte>
along with some parameters
<Kilo`byte>
that is actually a good idea
fowlduck has joined #crystal-lang
<jhass>
foo :: LibFoo::Bar will stack allocate it and foo = LibFoo::Bar.new will heap allocate it, iirc
<Kilo`byte>
now to get a pointer into an instance var
<jhass>
@foo = pointerof(foo)
<Kilo`byte>
just curious, do i have to manually delete the object?
<jhass>
nope
<jhass>
it's tracked by the GC
<Kilo`byte>
neat
<jhass>
if all references are gone it'll be collected
<Kilo`byte>
pointers count as references to it i assume?
<jhass>
I'd hope so
<jhass>
mmh, @foo :: LibFoo::Bar should work too
<Kilo`byte>
that can get messy if the c code makes a copy of it and it gets GCed while the c function still uses it
<jhass>
at class level at least
<Kilo`byte>
w/e you can probably work around that
<jhass>
Kilo`byte: yes, that's still an unsolved problem
<jhass>
I mean unsolved as in no nice API for it
<jhass>
the two approaches are to mark it as root for the GC or to keep a references in some global-ish thing
<Kilo`byte>
well, you can for now just keep a reference until you know the c function disposed it (eg. you called the delete function)
<jhass>
and usually you have a callback where you can unmark
<jhass>
yeah
<Kilo`byte>
add a flag to mark something as in use
<Kilo`byte>
or sth
<Kilo`byte>
then getters/setters
<Kilo`byte>
or alternatively a counter
fowlduck has quit [Ping timeout: 248 seconds]
<Kilo`byte>
not sure how libgc works though so that may not be possible
<Kilo`byte>
also apparently $?.success is NoReturn
<Kilo`byte>
wtf is the compiler smoking
daneb has quit [Remote host closed the connection]
<crystal-gh>
[crystal] PragTob opened pull request #898: Allow -h flag as a short version for --help (master...made-help-short-flag-work) http://git.io/vt2fQ
<ozra_>
Kilo`byte: Pointers are the only think the GC look for to see if objs are referenced, so yes.
<ozra_>
("Everyhting's" pointers behind the scenes, where you don't use them explicitly)
<ozra_>
As long as you have a pointer to data somewhere for the entire lifespan the C func needs it, you'll be ok. Otherwise you can allocate the memory manually via standard malloc and free with... free.
genixefr has quit [Ping timeout: 252 seconds]
genixefr has joined #crystal-lang
fowlduck has joined #crystal-lang
fowlduck has quit [Ping timeout: 248 seconds]
ytti has quit [Ping timeout: 258 seconds]
<ozra_>
When doing type introspection branching in a method and the argument type is known at compile time - is a specialization done of the method? Or does the check keep being done at run time?
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<BlaXpirit>
ozra_, as little runtime checking as possible
<crystal-gh>
[crystal] bcardiff pushed 1 new commit to master: http://git.io/vt2W9
<crystal-gh>
crystal/master 1842ba1 Brian J. Cardiff: Add Expressions#expressions to macro expander
NeverDie has quit [Quit: I'm off to sleep. ZZZzzz…]