05:22
riceandbeans has quit [Ping timeout: 252 seconds]
05:30
riceandbeans has joined #crystal-lang
05:30
riceandbeans has joined #crystal-lang
06:52
Ven has joined #crystal-lang
06:57
Ven has quit [Ping timeout: 250 seconds]
06:59
Ven has joined #crystal-lang
07:07
Ven has quit [Ping timeout: 272 seconds]
07:30
Ven has joined #crystal-lang
08:30
leafybasil has quit [Remote host closed the connection]
08:33
havenwood has quit [Remote host closed the connection]
08:39
ponga has joined #crystal-lang
08:41
ponga has quit [Client Quit]
08:45
ponga has joined #crystal-lang
08:46
panga has joined #crystal-lang
08:47
ponga has quit [Client Quit]
08:49
leafybasil has joined #crystal-lang
08:50
leafybasil has quit [Remote host closed the connection]
08:51
leafybasil has joined #crystal-lang
09:09
shadeslayer has quit [Ping timeout: 250 seconds]
09:10
shadeslayer has joined #crystal-lang
10:56
panga is now known as ponga
13:27
asterite has joined #crystal-lang
14:00
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
14:04
wanderer has joined #crystal-lang
14:08
<
wanderer >
asterite: hey, when I define functions with `def` or `fun` are they actually objects, too? also how can I take their address?
14:08
<
asterite >
They are not objects, but you can do this
14:09
<
asterite >
>> def foo; 1; end; proc = ->foo; proc.call
14:09
<
DeBot >
asterite: 1
14:09
<
asterite >
>> def foo(x); x + 1; end; proc = ->foo(Int32); proc.call 41
14:09
<
DeBot >
asterite: 42
14:10
<
wanderer >
ah. what about getting a `fun`s address instead of calling it?
14:11
<
asterite >
>> fun foo : Int32; 1; end; proc = ->foo; proc.pointer.address
14:11
<
DeBot >
asterite: 134519040
14:11
<
wanderer >
so it's possible with a `proc`-workaround?
14:12
<
wanderer >
I tried using `pointerof` which doesn't seem to work
14:13
<
asterite >
Possible what?
14:14
<
asterite >
Oh, you mean you tried pointerof(foo)?
14:14
<
wanderer >
I tried e.g. `pointerof(LibC.memset)`
14:15
<
asterite >
Oooh... I see what you mean. Now, that's not possible, but I think you should be able to do ->LibC.memset without specifying the types, because it's a C function... but right now you have to specify the types :(
14:15
<
asterite >
I'll add this to my todo list and later implement it :)
14:17
kostya has joined #crystal-lang
14:21
<
asterite >
But pointerof will never be used for that, because in the general case you need to specify the types of the arguments
14:22
<
asterite >
kostya: thanks again for those benchmarks! :-)
14:59
waj has joined #crystal-lang
15:06
havenwood has joined #crystal-lang
15:08
<
asterite >
I looked at google analytics because it was weird that suddenly people are commenting on the website :-P
15:09
<
asterite >
If you want to upvote, go ahead :)
15:10
<
jhass >
I don't even have a reddit account :P
15:11
<
wanderer >
me neither
15:12
<
wanderer >
ehm, how does pointerof actually work and when does it have to be used?
15:12
<
asterite >
Short answer: neve
15:13
<
asterite >
Longer answer: never, ever
15:13
<
asterite >
(kind of what Matz said about macros for Ruby :-P)
15:13
<
asterite >
Mmm... you use pointerof if you are doing low-level stuff, like dealing with pointers, or trying not to allocate unnecessary memory
15:15
<
wanderer >
so what exactly does it return?
15:15
<
jhass >
a Pointer :P
15:16
<
wanderer >
a = 0; pointerof(a); inside a function would return like `ESP + xx`, the address of the variable in the stack?
15:17
<
wanderer >
`esp - xx`, + would be the function's args
15:19
<
wanderer >
so does it only work for variables?
15:22
<
asterite >
Variables and instance variabels... for now
15:23
<
asterite >
I think it should also work for global variables, not sure that it does though
15:23
<
wanderer >
libgc exports GC_set_warn_proc and GC_ignore_warn_proc, and I'm trying to do `LibGC.set_warn_proc(pointerof(LibGC.ignore_warn_proc))`
15:31
<
asterite >
I think you need to do: LibGC.set_warn_proc(LibGC.ignore_warn_proc)
15:32
<
asterite >
Of course you need to define funs for set_warn_proc and ignore_warn_proc...
15:34
<
wanderer >
wouldn't just `LibGC.ignore_warn_proc` call the function?
15:43
<
asterite >
According to the GC docs, it returns a function
15:43
<
asterite >
So it's a function that returns a function :)
15:45
<
wanderer >
it's the function itself, it doesn't return one
15:48
ponga has quit [Quit: Leaving...]
15:56
kostya has quit [Quit: Leaving]
15:56
wanderer is now known as Guest69717
15:56
Guest69717 has quit [Killed (hitchcock.freenode.net (Nickname regained by services))]
16:04
wanderer has joined #crystal-lang
16:04
wanderer is now known as Guest45086
16:06
<
Guest45086 >
`fun ignore_warn_proc = GC_ignore_warn_proc` is the function I want to pass to `GC_set_warn_proc`, so I need to get its address
16:08
<
asterite >
You don't need its address, if you set the return type of `fun ignore_warn_proc` to a function, you can use that
16:08
<
asterite >
Wait, I'll show you
16:11
<
asterite >
Ah, mmm.. I don't understand what this means: GC_API void GC_CALLBACK GC_ignore_warn_proc(char *, GC_word);
16:11
<
asterite >
Is it a function pointer, or a function?
16:11
<
asterite >
C is cryptic
16:11
<
Guest45086 >
ignore_warn_proc doesn't return a function
16:12
shadeslayer has quit [Ping timeout: 252 seconds]
16:13
<
Guest45086 >
GC_API is a define for extern and GC_CALLBACK doesn't do anything
16:13
<
Guest45086 >
GC_ignore_warn_proc returns void
16:14
<
Guest45086 >
I want to declare it as a `fun` so that it gets imported, but it shouldn't be called, I just want its address
16:15
<
Guest45086 >
or like: `$ignore_warn_proc = GC_ignore_warn_proc : Void*; LibGC.set_warn_proc(pointerof(LibGC.ignore_warn_proc))`
16:20
<
asterite >
Try this: ->LibGC.ignore_warn_proc(UInt8*, UInt64)
16:20
shadeslayer has joined #crystal-lang
16:20
<
asterite >
or whatever the types of that function are... if you need the pointer, add ".pointer" to that
16:33
havenwood has quit []
16:56
<
Guest45086 >
do the types matter? I just need the function's address so I should be able to handle it as a function returning void, no?
16:56
<
Guest45086 >
`fun ignore_warn_proc = GC_ignore_warn_proc; proc = ->LibGC.ignore_warn_proc` crashes LLVM
16:56
<
asterite >
In this case the types don't matter, because there can be only one C function named like that. But the compiler doesn't know that yet... so for now you'll have to specify the types
17:02
<
Guest45086 >
>> lib LibGC; fun ignore_warn_proc = GC_ignore_warn_proc; end; proc = ->LibGC.ignore_warn_proc; proc.pointer
17:02
<
DeBot >
Guest45086: Pointer(Void)@B7647F40
17:03
<
Guest45086 >
hm, I get `llvm-3.5.1.src/lib/IR/Constants. , Line 1497 Expression: CastInst::castIsValid(opc, C, Ty) && "Invalid constantexpr cast!"`
17:05
<
asterite >
It's true, it's a bug
17:05
<
asterite >
If I compile that program with VERIFY=1 in the env var, it crashes
17:05
<
asterite >
I'll add it as a bug
17:05
<
asterite >
Maybe you can't get a pointer to a lib fun... I'm not sure
17:06
<
Guest45086 >
doesn't it just work with >> , though?
17:07
<
jhass >
haha, you gotta love reddit
17:07
<
jhass >
already in a meta fight
17:07
<
asterite >
The thing about Vala? :)
17:08
leafybas_ has joined #crystal-lang
17:08
leafybas_ has quit [Remote host closed the connection]
17:09
<
Guest45086 >
asterite: ok, but isn't `<DeBot> Guest45086: Pointer(Void)@B7647F40` correct?
17:11
<
asterite >
I think so, yes... it's strange that it's not working for you
17:11
leafybasil has quit [Ping timeout: 272 seconds]
17:14
<
Guest45086 >
asterite: is it maybe because I'm using LLVM 3.5.1?
17:14
<
Guest45086 >
like when trying LLVM 3.6.0 I had struct padding issues with `--release`
17:14
<
asterite >
Maybe, I'm using llvm 3.5.0
17:19
<
Guest45086 >
I'll compile 3.5.0 later and test that
17:21
asterite has quit [Ping timeout: 246 seconds]
17:21
Guest45086 has quit [Quit: Page closed]
17:22
bcardiff has joined #crystal-lang
17:59
leafybasil has joined #crystal-lang
18:11
havenwood has joined #crystal-lang
18:44
a5i has joined #crystal-lang
18:47
<
a5i >
Anyhow, What's the deal with Crystal and ruby gems? are they compatible? if not, whats the outlook for crystal 3rd party libs
18:48
<
jhass >
no they're not compatible, Crystal has Ruby inspired syntax but is a new language
18:48
<
jhass >
The package/library manager is still rather basic, it works by cloning repos at github and putting them into the right place
18:49
<
a5i >
Kinda like Rust
19:04
leafybasil has quit [Remote host closed the connection]
19:08
waj1 has joined #crystal-lang
19:11
waj has quit [Ping timeout: 256 seconds]
19:54
<
a5i >
jhass, so how can I use your bot framework? as In a sample irc bot script
19:55
<
jhass >
Mmh, it's not really structured in a way yet that you easily can
19:55
<
jhass >
you can clone the repo and copy the bot directory
19:55
<
jhass >
and then remove the plugins
19:56
<
jhass >
and write a new one ;)
19:57
<
jhass >
the basic structure is so I can extract it into separate repos later easily, but it's just not complete or definitive enough yet to do so :)
19:58
<
a5i >
btw, is Windows support coming soon?
19:59
<
jhass >
maybe, somebody is working on it
19:59
<
a5i >
Thats good, anyway so I cloned your repo
20:00
<
a5i >
and Im about to del the src folder of bot
20:02
<
a5i >
and now which file should I be running ?
20:04
<
jhass >
well, you deleted the bot, so you need to write a new one first
20:06
<
a5i >
Well there's where Im at
20:11
<
a5i >
Cannot find "framework/bot"
20:11
<
jhass >
to run it you need to be in the bot directory
20:11
<
jhass >
and no, you aren't
20:11
<
jhass >
you're about the third person to run this thing :P
20:12
<
jhass >
I had to push a simple fix, please pull
20:12
wanderer has joined #crystal-lang
20:13
wanderer is now known as Guest74837
20:17
<
a5i >
jhass, so I should add that file to the bot dir? (simple.cr)
20:17
leafybasil has joined #crystal-lang
20:17
<
jhass >
for example
20:17
<
jhass >
where it resides is actually not so important, that your working directory is the right one is ;P
20:21
<
jhass >
did you pull? :)
20:23
bcardiff has quit [Quit: Leaving.]
20:24
<
a5i >
Thanks, now it worked :P
20:28
<
jhass >
note that this is literally just what I needed to support DeBot, nothing extra ;)
20:28
<
jhass >
but you can make feature requests or even pull requests of course!
20:51
bcardiff has joined #crystal-lang
21:35
waj1 has quit [Quit: Leaving.]
22:12
bcardiff has quit [Quit: Leaving.]
23:10
havenwood has quit [Remote host closed the connection]
23:12
Guest74837 has quit [Quit: Page closed]
23:23
sadin has joined #crystal-lang
23:29
shama has joined #crystal-lang
23:35
<
a5i >
jhass, you available?
23:45
<
a5i >
jhass, any idea how to?
23:47
<
jhass >
a5i: create a Projectfile with: deps do; github "sferik/twitter-crystal"; end; then run crystal deps
23:51
<
a5i >
Everyone's been talking about Crystal ever since I posted that reddit thread today :o
23:51
shama has quit [Quit: (╯°□°)╯︵ɐɯɐɥs]
23:54
havenwood has joined #crystal-lang
23:54
<
a5i >
Hey havenwood
23:55
<
jhass >
a5i: oh, sounds like ancient git version
23:55
<
jhass >
it has that since 1.9 I think?
23:55
<
a5i >
Ima try to update my git then
23:56
<
havenwood >
a5i: hey