jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.5.8 | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/manastech/crystal - Docs: http://crystal-lang.org/docs/ - API: http://crystal-lang.org/api/ - Logs: http://irclog.whitequark.org/crystal-lang
jhass has quit [Quit: Bye]
jhass has joined #crystal-lang
zamith has quit [Quit: Be back later ...]
zamith has joined #crystal-lang
zamith has quit [Quit: Be back later ...]
leafybasil has quit [Ping timeout: 246 seconds]
sferik has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
zamith has joined #crystal-lang
zamith has quit [Ping timeout: 265 seconds]
sferik has joined #crystal-lang
zamith has joined #crystal-lang
zamith has quit [Ping timeout: 240 seconds]
<epitron> does anyone know what this build error is about? https://gist.github.com/eb813ac595ecbb49259f
<epitron> apparently i need to build with position-independant code
zamith has joined #crystal-lang
zamith has quit [Ping timeout: 245 seconds]
sferik has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
zamith has joined #crystal-lang
zamith has quit [Ping timeout: 276 seconds]
shama has quit [Quit: (╯°□°)╯︵ɐɯɐɥs]
zamith has joined #crystal-lang
zamith has quit [Ping timeout: 246 seconds]
zamith has joined #crystal-lang
zamith has quit [Ping timeout: 264 seconds]
CeBot has quit [Quit: Crystal]
CeBot has joined #crystal-lang
<jhass> epitron: you're on 32bits?
<jhass> mmh, no
<jhass> weird
<jhass> epitron: llvm-config --host-target might be interesting
<jhass> epitron: and might want to try crystal-git, master has some improvements in how we call LLVM
zamith has joined #crystal-lang
zamith has quit [Ping timeout: 276 seconds]
zamith has joined #crystal-lang
zamith has quit [Ping timeout: 256 seconds]
Cassyblanca has quit [Read error: Connection reset by peer]
Cassyblanca has joined #crystal-lang
zamith has joined #crystal-lang
zamith has quit [Ping timeout: 264 seconds]
zamith has joined #crystal-lang
zamith has quit [Ping timeout: 240 seconds]
zamith has joined #crystal-lang
zamith has quit [Ping timeout: 264 seconds]
zamith has joined #crystal-lang
zamith has quit [Ping timeout: 272 seconds]
leafybasil has joined #crystal-lang
zamith has joined #crystal-lang
zamith has quit [Ping timeout: 245 seconds]
zamith has joined #crystal-lang
zamith_ has joined #crystal-lang
zamith has quit [Read error: Connection reset by peer]
bcardiff has joined #crystal-lang
travis-ci has joined #crystal-lang
<travis-ci> manastech/crystal#1857 (master - 65d8ad5 : Ary Borenszweig): The build passed.
travis-ci has left #crystal-lang [#crystal-lang]
travis-ci has joined #crystal-lang
<travis-ci> manastech/crystal#1859 (master - 52f71d5 : Ary Borenszweig): The build passed.
travis-ci has left #crystal-lang [#crystal-lang]
asterite has joined #crystal-lang
travis-ci has joined #crystal-lang
<travis-ci> manastech/crystal#1860 (master - ff2b32e : Ary Borenszweig): The build passed.
travis-ci has left #crystal-lang [#crystal-lang]
<jhass> asterite: working on MatchData#[]? and the like ;)
<asterite> Cool :)
<asterite> A lot of things are just left overs from when we actually started the language, so I guess there will be many more “small” things like this to clean up
<asterite> I like it that you kept the [] / []? convention
<jhass> I think it's a very useful one
<jhass> I sometimes imagine []? as a shortcut to has_key?() has_match?() etc
<asterite> I think it lets you program like in Ruby (raise exception) or Go/Erlang where you have to explicitly deal with the “error” branch
<asterite> Yes, also that
<jhass> foo[x] if foo[x]?
<jhass> can always optimize that codepath if turns out to be critical ;)
<jhass> but I think it reads nicely that way
asterite_ has joined #crystal-lang
<asterite_> Well, that was fast :)
asterite has quit [Ping timeout: 246 seconds]
asterite_ is now known as asterite
<zamith_> asterite: I have finished the specs refactor
zamith_ is now known as zamith
<zamith> you can merge ir if you want
<asterite> Oh! I saw it yesterday but didn’t have my computer. Then I forgot about it, sorry! (I have a bad memory some times)
<asterite> Thanks! I’ll merge it soon :)
<zamith> np
<zamith> ;)
<asterite> “220 additions and 389 deletions” is very good :)
travis-ci has joined #crystal-lang
<travis-ci> manastech/crystal#1862 (master - 896f9c5 : Ary Borenszweig): The build passed.
travis-ci has left #crystal-lang [#crystal-lang]
asterite has quit [Quit: asterite]
asterite has joined #crystal-lang
asterite has quit [Client Quit]
<zamith> I think so
asterite has joined #crystal-lang
<jhass> asterite: I don't think we can upstream Thread#name=: http://stackoverflow.com/questions/2369738/can-i-set-the-name-of-a-thread-in-pthreads-linux
<jhass> second answer
<asterite> So why we can’t upstream it?
<jhass> it's not portable at all
<asterite> Ah, I see. Maybe that’s why it’s not there in Ruby
<jhass> yeah
<jhass> glibc 2.12 isn' that old either I guess
<asterite> You were using it for debug purposes?
<jhass> kind of, I also like it when I can see what things are in my process hierarchy
<asterite> Well, we could have those methods do nothing in the systems where it’s not supported
<jhass> I'd rather not, I think that's too unexpected
<asterite> Ok
<jhass> mh, I suppose you don't see a way where I could read some json, having only parts of it in json_mapping and dumping the parts I don't have in there back unchanged?
<jhass> or do that with any method really
<asterite> Back unchanged as a string or as a Json::Type?
<jhass> don't really care too much about the crystal side except that I don't know all keys, I know only the key I want to change but not loose everything else
<jhass> can the regular json parser do it?
<asterite> Ah, I see. Yes, this is something I also needed a couple of times. I guess we would need to enhance json_mapping to suport it (I think also enhance JSON:PullParser). JSON::Parser could do it, but I don’t know what’s the interaction between it and the pull parser would be
<asterite> The regular json parser does it, but it works for the whole json, not for parts of it
<asterite> I guess we could have something like `json_mapping({value: JSON::Any})`, and have JSON::Any.new(JSON::PullParser) create a JSON::Type (the union of all possible types)
<asterite> It would be nice to use value: JSON::Type, but there’s no way to add methods to a type alias (and I don’t think we’ll have support that)
<jhass> mh, sounds interesting
<asterite> We originally wrote the generic parser, but soon realized it would be a pain to work with a generic object like that, because of the static type aspect of the language
<asterite> so then we thought about the pull parser, and we were able to quickly map objects (without the macro)
<asterite> then came the macro
<jhass> :D
<asterite> so that’s why the parser is like a different beast. But both use the lexer at the bottom
<asterite> Would you be interested in doing the JSON::Any thing?
travis-ci has joined #crystal-lang
<travis-ci> manastech/crystal#1863 (master - 72ae25a : Ary Borenszweig): The build passed.
travis-ci has left #crystal-lang [#crystal-lang]
<asterite> I can do it, but I’ll probably do it in some time in the weekend or next week
leafybasil has quit [Remote host closed the connection]
<jhass> not sure yet, I think I'll try first whether I can do what I want with the regular one
<asterite> Ok. I’ll try to do it then, I think it’s very useful and needed
<asterite> I’m really amazed that people like you and ysbaddaden try to build apps with Crystal, despite the language being so young, and in the meantime feeling all the gaps, even if those gaps mean interfacing with very low-level C :-)
<asterite> filling
asterite_ has joined #crystal-lang
asterite has quit [Ping timeout: 276 seconds]
asterite_ is now known as asterite
<jhass> heh, it's part of the fun ;)
<jhass> doing low level stuff in a language that has the syntax like a highly abstracted one, in fact being able to transition between the two styles of programming so seamlessly is something new to me and very exciting ;)
<asterite> :)
<asterite> I sometimes like to see Crystal as C with a unified, clean syntax (so a pointer doesn’t have a special semantic and it looks like a regular object), plus with many accumulated knowledge already there (sockets, json, array, hash), and a GC for not having to think (too much) about memory
<jhass> mmh
<asterite> Or at least as a very thin layer on top of C
<jhass> I'd like to add most of the errno constants
<jhass> gotta find a way to generate that I guess
<jhass> maybe manpage parsing?
<asterite> You want to do that at compile-time?
<jhass> not necessarily
<jhass> but they're all over the place
<asterite> Where?
<jhass> nothing you can copy paste and edit
<jhass> various headers
<asterite> Aaaah… I see
<jhass> errno.h and bits/errno.h is pretty empty
<asterite> But where do you use an errno value?
<asterite> Not sure its complete, though
<jhass> EINTR can happen due to spurious wakeups
<asterite> I see
<jhass> but I think it would be good to have at least those for the posix calls available
<jhass> can you quickly check whether your link matches OS X stuff?
<jhass> then I'd say we just start of with these as a base
<asterite> I’ll check
<epitron> jhass: I got the same error building with the git one
<jhass> epitron: meh :/
<jhass> so what's your llvm-config --host-target
<jhass> does the statically linked one you can download from github releases work?
<asterite> jhass: EAGAIN is 11 in that page and 35 on my headers :(
<jhass> :(
<asterite> I guess we’ll have to use ifdef for all the values
<epitron> jhass: I'll tell you in a bit
sferik has joined #crystal-lang
<jhass> if you just gist me your grep -PR "#define\s+E[A-Z]+" /usr/include I think it'll be okay
<jhass> asterite: ^
<jhass> scrap that, gotta refine the regex
<jhass> "#define\s+E[A-Z]+\s+(E[A-Z]+|\d+)"
<jhass> should be better
<asterite> What’s the P flag? It doesn’t exist on mac
<jhass> try E
<jhass> it's PCRE
<jhass> alright, I'll match that up
<asterite> It was simpler than what I thought
<jhass> nice
<jhass> thanks
sferik has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
travis-ci has joined #crystal-lang
<travis-ci> manastech/crystal#1864 (master - 9f7b5df : Ary Borenszweig): The build passed.
travis-ci has left #crystal-lang [#crystal-lang]
<jhass> asterite: got 44 codes from the blog that are not in the gist, should I just remove them, so both have the same codes defined?
<asterite> Sounds fine
sferik has joined #crystal-lang
<zamith> asterite: how does JSON::Any work?
<zamith> it tries to infer the type?
<zamith> oh, the PullParser already does that?
<asterite> It basically returns a union of all possible json types
<asterite> The type is actually a union, not a JSON::Type, but that alias makes it possible to write `[] of JSON::Type` to insert that union and being able to talk about it :)
<zamith> oooh
<zamith> then I still have to type cast the values, for type specific methods, right?
<asterite> Yes. But you’d normally use JSON::Any when you are not interested in that value, but still want to keep it so when you serialize back the value it’s unchanged
<asterite> At least that’s what jhass needed (and me, a couple of times)
<asterite> Another possiblity would be to keep the raw json value as a string, maybe with a possible JSON::Raw mapping, which would be much more performant, but for now I guess it’s ok
<zamith> I haven't used json_mapping a lot
<zamith> I'll try to work more on crystalshards
<asterite> I used it today to see if prax.cr was there :)
<zamith> it will probably surface a few issues with frank
<zamith> oh really?
<zamith> nice
<zamith> it's really ugly
<zamith> though
<zamith> :s
<asterite> I think it’s a very nice project. I’d sort the project by “when was the last commit” or maybe the amount of stars or some kind of activity
tymat has quit [Ping timeout: 252 seconds]
<zamith> yeah, true
<asterite> So you can see “abandoned” or “let’s try this language… ok, enough” projects at the bottom
<zamith> I also want to add search
<zamith> and pagination
<zamith> right now it only shows 100 projects
<zamith> :S
<asterite> I think the 100 limits is fine for now, I don’t believe there are more than 30 or so right now
<zamith> pagination of the github requests i mean
<zamith> there are about 40
<zamith> I added the total to the site
<zamith> :p
<asterite> I used to use the “trending Crystal repos” in github, but your website is much more useful and accurate
<zamith> another thing is to have a community based voting system or flaggin system
<zamith> there are some projects there that are not crystal
<zamith> but github thinks they are
<asterite> Yes, those critter-related projects
<zamith> ans some that are not crystal deps compliant
shama has joined #crystal-lang
<jhass> they stole our file extension! :P
<asterite> There was actually another language that wanted to use the .cr extension. He found out when its files suddenly became colored in github :)
tymat has joined #crystal-lang
<jhass> :D
<zamith> hahahah
<zamith> poor fellow
<asterite> It seems github now colors it too :)
<zamith> yes, it supports the cirru language now
<zamith> gosh, there are a lot of languages
<zamith> :p
<asterite> zamith: are you familiar with it?
<zamith> nope
<zamith> but you can see in the repo
<zamith> under the number of commits, contributors and such
<zamith> if you click the colored line, you can see the language stas
<zamith> *stats
<asterite> Ah, yes
<asterite> jhass: check that travis failed, it seems there’s a duplicated constant. You can try to compile with —cross-compile in your machine to easily see if there are other dups
<jhass> oh, right
<jhass> I know I should've compared line counts :P
zamith has quit [Ping timeout: 245 seconds]
<asterite> Don’t worry, that’s why there’s a build server :)
<jhass> another wild idea for the json stuff: allow passing JSON::Type/JSON::Any to the pull parser, which then would do the casts on the read_xx calls
<jhass> then for example you could feed an attribute of a mapping conditionally to another mapping
<jhass> do you think that could work?
<asterite> How’s that? I don’t really understand what you say. Maybe an example? :)
<jhass> let me try
<jhass> let's say we have class A; json_mapping{a: String, b: JSON::Any}); end; and class B; json_mapping({c: String}); end; then I think it would be nice if you could do a = A.from_json(read_file); if a.some_weird_condition; b = B.from_json(a.b); end
<jhass> I know, that'll probably require some larger reworkings of the pull parser, or writing a child class of it or something, as said just a wild idea
<asterite> Or, you mean like storing a “pointer” to the pull parser so another type could parse from there?
<jhass> maybe, though I think I'd like the flexibility to use either variant, the current one and that
<asterite> Why wouldn’t you map it directly into A if you know the type?
<asterite> Or the type will be based on a certain condition?
<jhass> yes, that's why I had that idea
<jhass> in fact I'd like to manually read the object from the parser and then have a condition on which I choose the types of the values for
<asterite> Yes… in that case right now you need to do implement self.new(PullParser) and do that logic there… it’s kind of tedious. But yeah, we might need to do it better
<jhass> anyway, currently I just parse it twice, it's a small file, so it's okay for now ;)
<jhass> (I know, I could pass my custom type to the mapping, but I need to pass other stuff along)
<jhass> while we're at wild ideas, what do you think about class Foo(T); def bar; T::Bar.new; end; end; ?
<asterite> Does that work?
<jhass> nope :P
<jhass> I wonder if we would like it to ;)
<jhass> probably not because T can be a union
<asterite> Yes, I was thinking the same. But I think it should work right now and (maybe) crash the compiler on a union, but it doesn’t even work
<asterite> We could make it work. It can lead to nice patterns, I think
<asterite> What would you use it for?
<asterite> (it doesn’t work right now probably because it’s a bug)
<jhass> class PluginContainer(T); def config; @config ||= T::Config.new; end; end; essentially
<jhass> right now I just do PluginContainer(T, J)
<jhass> with J being T::Config in a macro
<asterite> Ah, I see. I’ll fix it, the T:: should, and give an error if it’s a union
<jhass> cool!
<asterite> Yes, from time to time travis gives that error and it takes some time until it recovers
<jhass> >> def foo(x : T); T::Baz; end; foo(1 || 1.5)
<CeBot> jhass: Failed to run your code, sorry!
<jhass> heh
sferik has joined #crystal-lang
CeBot has quit [Quit: Crystal]
CeBot has joined #crystal-lang
<jhass> >> def foo(x : T); T::Baz; end; foo(1 || 1.5)
<CeBot> jhass: Bug: (Int32 | Float64) doesn't implement lookup_type
<jhass> ;)
<jhass> epitron: how about I upload a build package and you can try if it works for you?
travis-ci has joined #crystal-lang
<travis-ci> manastech/crystal#1867 (master - a5d9c9d : Ary Borenszweig): The build passed.
travis-ci has left #crystal-lang [#crystal-lang]
bcardiff has quit [Quit: Leaving.]
r20 has joined #crystal-lang
asterite_ has joined #crystal-lang
asterite has quit [Ping timeout: 272 seconds]
asterite_ is now known as asterite
sferik has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
shama has quit [Quit: (╯°□°)╯︵ɐɯɐɥs]
sferik has joined #crystal-lang
<jhass> asterite: before I spend time writing specs, would you be interested in such a thing: https://github.com/jhass/crystal/commit/8d6d7f28bc296cb4824f1792f90e20a8c53b1fb0
<jhass> and would you be okay with the design
<asterite> Cool! I’ll take a look at it a bit later
<asterite> But, if you have an example it will help me to understand how to use it :)
<jhass> was just going to paste it http://paste.mrzyx.de/pamhnouzr
<jhass> it doesn't include the actual usecase, but it shows how it would be used
<jhass> my real code does dynamically pull the mapping based on the key
<asterite> Ah! So instead of parsing json you parse the possible values of JSON::Type?
<jhass> yup
<epitron> jhass: sure! I'll try it when I get home
<asterite> jhass: why not parse it from the json string?
<asterite> There’s something I don’t understand, but maybe it’s because I’m tired from work :-P
<jhass> can I keep the raw json for an attribute in a mapping?
<jhass> or how would that work?
<asterite> Not right now, but we could make it work
<asterite> But why not specify the mapping in json_mapping instead of using Any?
<jhass> because I don't know it there
<asterite> So you know it based on some other value?
<asterite> Then you do a case of some sort?
<jhass> based on a value in the json in fact
<jhass> in the concrete example, plugins points to an object
<asterite> The problem is that that value might come later in the json, right?
<jhass> whose keys are the Plugin names
<jhass> and the values there are then things I want to parse into mappings again
<jhass> so I need to map the keys to the mapping
<jhass> and I don't really know them at that point
<jhass> I don't even know which plugin names will appear in the json, they're all optional
<jhass> Currently I just parse the json twice
<jhass> first, ignoring plugins
<jhass> second time with the pull parser directly fishing out the plugins key
<jhass> and then iterating through that object and instantiate the actual mappings that appear
<asterite> Could you do json_mapping({plugins: MyPluginParser}) ?
<jhass> I tried
<jhass> a lot
<jhass> since I can pass nothing in there
<jhass> I have to use a global registry
<asterite> Can you show me where in the code you do the second parsing?
<jhass> and the union of the possible mappings totally exploded
<asterite> And where do you initialize config.plugins with the key/values?
<asterite> And right now you don’t have a global registry? The current registry is the Framework::Bot?
<asterite> (instance)
<jhass> yes
<jhass> I really tried one
<asterite> What’s wrong with a global registry? :)
<jhass> @@registry = Hash.new(String, Configuraiton::Plugin).new -> nope
<asterite> Why not?
<jhass> I had so many variants dunno, it didn't accept the child classes
<jhass> I think
<asterite> Oh!
<asterite> I see
<jhass> I tried storing procs and let crystal interfere the return value
<asterite> You have to do Hash.new(String, Configuraiton::Plugin.class)
<asterite> Note the “.class” there
<asterite> Then you can actually create the registry with the `inherited` macro
<jhass> which actually hit a compiler bug I think
<asterite> I used it in one project of mine
<jhass> I mean in the end I could avoid global state
<jhass> currently I could run multiple instances of the bot in the same program, I think (granted, I didn't try)
<jhass> so, I'll just keep the two times parsing if you don't like the union parser (which probably could have a better name...)
<asterite> I think I like the idea. It’s just that I have to see it and use it, or maybe think what are the current limitations right now
zamith has joined #crystal-lang
<asterite> jhass: I have this
<asterite> If I use `new` instead of `magic` there: https://gist.github.com/asterite/f73d23c2810dcb1f7b97#file-magic-cr-L32 I get a compile error
<asterite> but that’s a bug
<jhass> yeah well, I was close then I guess
<asterite> :)
<asterite> But would that work for you?
<jhass> Honestly, I'm too tired of it to try atm
<jhass> spend too much time at that part, parsing twice is fine for now, it's just a small file
<jhass> and the code is actually smaller
<jhass> sort of
<jhass> and there's no global state except for in two plugins themselves, but not in the framework
<jhass> iirc at least
<jhass> I think I even tried doing Plugin:Class at one point
<jhass> since that was in one of the error messages
<jhass> syntax error, obviously
<asterite> Yes. Well, the `.class` in a type is not very known and it’s not documented, so… and previously it had some bugs, but now it seems to be working more or less
<asterite> Still, parsing a json from the type in memory is interesting :)
<asterite> Gotta go now… bye!
asterite has quit [Quit: asterite]
asterite has joined #crystal-lang
<asterite> jhass: I think that with my gist and the possibility to iterate the subclasses of a type at compile-time, that global state would go away. But first I'll fix a few bugs
<jhass> I see if I can make the union parser work anyway
<jhass> I mean it works for json_mapping
<jhass> but emulating the read_next api is hard
sferik has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sferik has joined #crystal-lang
sferik has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<asterite> I think we could include your json union parser. I'm not sure it will be needed though, if we have more powerful metaprogramming capabilities
<asterite> Which in fact I just commited :)
<asterite> Of course I'm cheating, because I added more things to the language and fixes some bugs ;-)