jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.11.1 | Fund Crystals development: http://is.gd/X7PRtI | 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
trapped_ has quit [Read error: Connection reset by peer]
<travis-ci> MakeNowJust/crystal#17b8846 (master - Merge pull request #2119 from waj/feature/sigfault-handler): The build passed. https://travis-ci.org/MakeNowJust/crystal/builds/108425631
<DeBot> https://github.com/manastech/crystal/pull/2119 (Feature/sigfault handler)
elia has quit [Quit: Computer has gone to sleep.]
sdogruyol has joined #crystal-lang
sdogruyol has quit [Ping timeout: 252 seconds]
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/vgrP2
<crystal-gh> crystal/master e067f80 Ary Borenszweig: Formatter: handle `&.[](...)` and other variants. Fixes #2133
fowlduck has quit [Remote host closed the connection]
<travis-ci> manastech/crystal#e067f80 (master - Formatter: handle `&.[](...)` and other variants. Fixes #2133): The build passed. https://travis-ci.org/manastech/crystal/builds/108437785
grindhold has joined #crystal-lang
grindhold_ has quit [*.net *.split]
fowlduck has joined #crystal-lang
<crystal-gh> [crystal] kostya opened pull request #2138: Cookies some fixes (master...cookies_fix) https://git.io/vgrMV
pawnbox_ has quit [Ping timeout: 276 seconds]
sdogruyol has joined #crystal-lang
sdogruyol has quit [Ping timeout: 240 seconds]
pawnbox has joined #crystal-lang
Philpax_ has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
shama has quit [Remote host closed the connection]
Philpax has quit [Ping timeout: 276 seconds]
sdogruyol has joined #crystal-lang
pawnbox has joined #crystal-lang
sdogruyol has quit [Ping timeout: 276 seconds]
dylanmei has joined #crystal-lang
dylanmei has left #crystal-lang [#crystal-lang]
pawnbox has quit [Remote host closed the connection]
Philpax_ has quit [Ping timeout: 240 seconds]
fowlduck has quit [Remote host closed the connection]
fowlduck has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
kfpratt has quit [Ping timeout: 252 seconds]
kfpratt has joined #crystal-lang
trapped has joined #crystal-lang
omninonsense is now known as [spoiler]
_kfpratt has joined #crystal-lang
kfpratt has quit [Ping timeout: 252 seconds]
Philpax_ has joined #crystal-lang
<crystal-gh> [crystal] MakeNowJust opened pull request #2140: Improve URI#escape and URI#unescape (master...feature/escape-unescape-with-block) https://git.io/vgot8
<crystal-gh> [crystal] MakeNowJust opened pull request #2141: Escaping missing (master...patch-2) https://git.io/vgota
pawnbox has joined #crystal-lang
trapped has quit [Read error: Connection reset by peer]
<Davy_CC> >> class A; property a; def initialize; @a = 1; end; def show; puts a += 1; end; end; A.new.show
<DeBot> Davy_CC: Syntax error in eval:21: '+=' before definition of 'a' - https://carc.in/#/r/rzb
<Davy_CC> >> class A; property a; def initialize; @a = 1; end; def show; puts a = a + 1; end; end; A.new.show
<DeBot> Davy_CC: 2 - more at https://carc.in/#/r/rzc
<Davy_CC> It seems that `a += b` won't parse as calling `a=(a + b)` ?
<BlaXpirit> Davy_CC, this is interesting but kinda makes sense
elia has joined #crystal-lang
<Davy_CC> why
<BlaXpirit> i suppose normal assignment is a special case that introduces a new variable
<BlaXpirit> Davy_CC, note that in your 2nd example @a didn''t change
<Davy_CC> I think `a += b` is equals to `a = a + b`, isn't it?
<BlaXpirit> Davy_CC, yes but not exactly as you can see
<BlaXpirit> it does some checks before rewriting
<Davy_CC> >> class A; property a; def initialize; @a = 1; end; def show; puts a = a + 1; end; end; a = A.new.show; a.a
<DeBot> Davy_CC: undefined method 'a' for Nil - https://carc.in/#/r/rzd
<Davy_CC> >> class A; property a; def initialize; @a = 1; end; def show; puts a = a + 1; end; end; a = A.new; a.show; a.a
<DeBot> Davy_CC: 2 - more at https://carc.in/#/r/rze
<BlaXpirit> well apparently I know nothing
<BlaXpirit> wait, it actually writes 2 then 1
<BlaXpirit> so i was correct
<Davy_CC> I am curious why there is a statement after raise here: https://github.com/manastech/crystal/blob/master/src/compiler/crystal/syntax/parser.cr#L346
<Davy_CC> but you're right, it didn't change @a...
<BlaXpirit> O_o
<BlaXpirit> blame to the rescue
<BlaXpirit> heh that tells nothing, it was all added in 1 commit. very strange
toydestroyer has quit [*.net *.split]
<Davy_CC> very strange
pawnbox has quit [Remote host closed the connection]
toydestroyer has joined #crystal-lang
toydestroyer is now known as Guest51001
<Davy_CC> >> class A; property a; def initialize; @a = 1; end; def show; self.a = a + 1; end; end; a = A.new; a.show; a.a
<DeBot> Davy_CC: # => 2 - https://carc.in/#/r/rzj
<Davy_CC> it works after I added `self.` before `a`
Excureo has quit [Ping timeout: 248 seconds]
Excureo has joined #crystal-lang
<Davy_CC> BlaXpirit: you're right, on normal assignment, it creates a new variable, not calling `a=` method
<BlaXpirit> yes..
<Davy_CC> it wired, because when we use `a` it calls `a` method, but use `a=` it doesn't call `a=` method until using `self.a=`
pawnbox has joined #crystal-lang
fowlduck has quit [Remote host closed the connection]
pawnbox has quit [Remote host closed the connection]
sdogruyol has joined #crystal-lang
<Davy_CC> BlaXpirit: is `1 <= 5 < 9` equals to `1 <= 5 && 5 < 9` ?
<BlaXpirit> Davy_CC, i don't know
<Davy_CC> >> 1 <= 5 < 9
<BlaXpirit> it might
<DeBot> Davy_CC: # => true - https://carc.in/#/r/rzn
<BlaXpirit> >> (1 <= 5) < 9
<DeBot> BlaXpirit: undefined method '<' for Bool - https://carc.in/#/r/rzo
<BlaXpirit> sure
<Davy_CC> cool syntax
<BlaXpirit> Davy_CC, on previous topic, that's documented behavior
<BlaXpirit> you can add a variable to a class at any point in the code
<BlaXpirit> why should it change the behavior of a method that happens to be using a local variable with the same name
fowlduck has joined #crystal-lang
<Davy_CC> ok, i know it now
sdogruyol has quit [Remote host closed the connection]
<Davy_CC> >> class A; property a; def initialize; @a = 1; end; def show; puts a=(a + 1); end; end; a = A.new; a.show; a.a
<DeBot> Davy_CC: 2 - more at https://carc.in/#/r/rzr
<BlaXpirit> Davy_CC, you pretty much changed nothing from the previous example
<Davy_CC> yes i know
elia has quit [Read error: Connection reset by peer]
elia_ has joined #crystal-lang
<Davy_CC> so `a=` and `a =` is different
<BlaXpirit> Davy_CC, uh no it isn't
<Davy_CC> oh i forgot to remove that `puts`
<Davy_CC> sorry
<Davy_CC> so the only way i can change the property is using `self.a=` not `a=`
<BlaXpirit> Davy_CC, yes, and exactly that is written somewhere in http://crystal-lang.org/docs
<Davy_CC> I'm reading it and doing some try and error. Could you tell me which page points out the behavior you mentioned? thanks
elia_ has quit [Read error: Connection reset by peer]
elia has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
<BlaXpirit> sorry that i didn't reply. no, i don't remember exact page
<BlaXpirit> I recommend reading everything, then trying
<BlaXpirit> aand apparently I was wrong that it is written there :(
srenatus has joined #crystal-lang
sdogruyol has joined #crystal-lang
sdogruyol has quit [Client Quit]
<BlaXpirit> i've been trying to come up with some game idea to write for practice
<BlaXpirit> but nothing interesting ever comes to mind
pawnbox has joined #crystal-lang
ssvb has quit [Read error: Connection reset by peer]
pawnbox has quit [Remote host closed the connection]
alanwillms has joined #crystal-lang
xender has joined #crystal-lang
<xender> Hi. I'm new to Crystal and I'd like to ask about cross-compiling: I already know it's not possible to bootstrap the compiler on Windows at the moment, but is it possible to cross-compile *for* Windows at all? If so, which parts of standard library can I use and which I can't?
pawnbox has joined #crystal-lang
alanwillms has quit [Quit: Saindo]
pawnbox has quit [Remote host closed the connection]
fowlduck has quit [Remote host closed the connection]
elia has quit [Read error: Connection reset by peer]
elia has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
<Davy_CC> xender: I'm keeping moving Crystal 0.9.1 to Windows. Standard library depends on many unix only library, we have two choice, one is using Cygwin or other unix capitable layer; the other is moving standard library to use Windows APIs.
trapped has joined #crystal-lang
<Davy_CC> I'm trying to let Crystal use Windows APIs. But I'm poor at it, so I have to do much research between these libraries and Windows APIs. But if you want, you can try cross-compile with Cygwin first.
elia has quit [Read error: Connection reset by peer]
<xender> Davy_CC: Well, how about MinGW?
<xender> I suspect Cygwin can have problems with wide acceptance among Windows users, but MinGW seems to be pretty popular option.
<Davy_CC> all unix capitable layer is okay, but I haven't try them yet
<xender> It doesn't really implement some heavily-UNIX-specific things, though
elia has joined #crystal-lang
<xender> With MinGW, you get standard libc (GNU libc I think), you can get pthreads, but no fork()
<xender> There is fork() on Cygwin, but it's evil hack anyway...
<Davy_CC> yes, so if you want to use MinGW, you have to implement one or remove fork()
<xender> Removing fork() on Windows is the only sensible option.
luislavena has joined #crystal-lang
<Davy_CC> but we can provide some windows APIs on Crystal, like CreateProcess
<xender> It's the same situation as if you were developing a new language on Windows, making it expose some WinAPI functions as a window into low-level API, and then wondering what to do with them when porting to Linux. "Should we use Wine for this?"
<xender> Actually, people who were making .NET were not even that nice, Mono devs were on their own :P
<xender> Well, I don't know much about Crystal and it's stdlib yet, but the real answer is that there needs to be some abstraction.
fowlduck has joined #crystal-lang
<Davy_CC> btw, here is the discussion for the compiler on windows https://github.com/manastech/crystal/issues/26
<xender> As Crystal looks pretty nice and high-level, I would expect something like Python's 'subprocess' module, not just having bare fork, exec and CreateProcess exposed
<xender> Yeah, I've seen the discussion, thank you for pointing it though.
<Davy_CC> Crystal's Standard Library is the abstract layer, and keeping moving to be a high-level layer
<xender> So I think the real answer is to expose low-level system functions only on systems where they are implemented, and have high-level functionalities covered by abstraction layer.
<xender> It's no different than coding in C++ - trying to use fork() on *NIX or Cygwin will work (or somehow work), but under MinGW or MSVC it will be a compile-time error
trapped has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<xender> There have been some discussion about what's more proper to do on fork()-less platform: an exception or a compile-time error. The latter is only sensible option to me...
ponga has quit []
<Davy_CC> I think Windows is not a POSIX-capitable system, so I won't implement fork() on Windows
elia has quit [Read error: Connection reset by peer]
elia has joined #crystal-lang
<BlaXpirit> Davy_CC, good
<xender> Davy_CC: You can take a look at how Cygwin folks have done it. Maybe it will scare you :P
<Davy_CC> But in my opinion, standard lib will provide a method calls fork() on POSIX, and a method calls CreateProcess on Windows. But they won't be the same method in standard lib.
<xender> Of course
<xender> They should be in different modules
<Davy_CC> xender: I know that's so terrible
<xender> Separate modules for underlying OS API-s...
<Davy_CC> BlaXpirit: good for what
<xender> Davy_CC: So you know that they spawn a new process from the same executable in suspended state, set some flag in there, let it execute until entry point (which contains Cygwin-provided code as it was compiled by Cygwin's GCC), which then checks the flag, then parent copies it's own memory into child address space, which triggers some antivirus software and bloats the RAM...
<BlaXpirit> not implementing fork on windows is good
<xender> Nightmare, horror and terror in one ^ ^
<Davy_CC> BlaXpirit: lol many languages aren't implementing fork on windows :P
<BlaXpirit> good
<xender> Though, Cygwin's compiler detects fork+exec, so it can substitute the pair with a normal-ish CreateProcess.
<Davy_CC> we are not talking about Cygwin lol
<xender> Davy_CC: But you were mentioning the mere possibility that implementing fork() on Windows could be done... So I thought mentioning how exactly terrible Cygwin's implementation (the only one I know) is. :P
<Davy_CC> I know using Cygwin is a bad idea. So I'm porting Crystal to Windows without Cygwin and MinGW
<Davy_CC> many of libraries Crystal used have windows version
<xender> No, Cygwin itself is not a bad idea
<xender> Their implementation of fork isn't either. It's terrible because that's the only way.
<xender> I also don't know to what extent MinGW can interface with MSVC-compiled libraries.
<xender> But I'd be more inclined towards supporting MinGW than MSVC.
<xender> It would be best to support both, but MinGW is more familiar when you're coming from Linux/UNIX background, and it has a free license.
<Davy_CC> Crystal uses many portable libraries, so I think it would be ok on MinGW.
trapped has joined #crystal-lang
<Davy_CC> gc-lib, libpcre, libevent (event2) are working on Windows. The only problem is libunwind seems not have windows version.
<Davy_CC> maybe i'll use windows api to solve it
<xender> SEH?
<xender> (Structured Exception Handling) - native Windows exception handling
<xender> Just don't make the mistake of some implementors of C++ exceptions who used SEH...
<xender> I think it was on some old versions of MSVC...
<xender> Doing catch(...) (catch all exceptions) in C++ catched all SEH exceptions, not only C++ exceptions
<xender> So also things like segfaults I think? :D
<BlaXpirit> neat
<xender> They took "catch-all" too literally ^ ^
<Davy_CC> how about RtlUnwind?
<xender> Hmm
<xender> How about compiling to C++ and let it handle unwinding the stack? :P
<Davy_CC> xender: btw, you can try cross-compile with empty prelude (means without standard libs). here's the way https://github.com/david50407/crystal/blob/windows/README.win32.md
<xender> Davy_CC: Will I have GC or access to built-in types like Array?
<Davy_CC> compile with that branch of code, it will use `gc/null`
<xender> So no GC?
<Davy_CC> I've already solve GC problem by using windows version libgc, but I haven't commited yet because of unsolved unwind.
<xender> Hmm
<Davy_CC> yes
<xender> Wouldn't compiling to C/C++ be a real option?
<Davy_CC> do you know how to use SEH on windows?
<xender> Well, LLVM has -march=C and -match=cpp
<xender> I don't know. I switched to Linux long ago
<Davy_CC> Crystal is compiling to LLVM-IR, maybe you can compile to C++
<Davy_CC> s/is/can be/g
<xender> Hmm
<xender> Does LLVM-IR have any notion of exceptions/unwinding?
<Davy_CC> i don't know
<xender> Would it be possible to just use this instead / as an alternative to libunwind?
<xender> Also, what about things like Emscripten that allow compiling LLVM-IR to Javascript?
<Davy_CC> I'll read this later. But there must a reason Crystal didn't use this instead of libunwind.
<BlaXpirit> wise words
<xender> The problem is that libunwind seems to be horribly unportable
<xender> Or no, that's not the real problem
<xender> The real problem is that it's separate from the rest of compiler pipeline...
<xender> Also, programmers with different backgrounds have different expectations about how often exceptions occurs, how reliable are they etc.
<xender> Python programmers use exceptions commonly, but in C++ people sometimes disable it altogether.
<xender> So a C++ programmers reaction might be "come on, it shouldn't throw in the first place / when it throws we are screwed anyway" and Python's programmer reaction will be "you're trying to take integral path of the language from me? Are you nuts?"
<xender> So the point is: it should be decided/agreed upon and documented what is the intended use case for exceptions, can programmers rely on them heavily or not...
<xender> It probably needs to wait as there are more urgent things to do I suppose :D
<waj> xender: Crystal actually uses LLVM exception handling
<xender> Ok...
<waj> Core unwind functions (not libunwind) are used to raise exceptions and stack unwind
<xender> So is libunwind used for something different?
<waj> no, what do you mean?
<xender> Is it not used at all then?
<xender> Then why Davy_CC mentioned it?
<waj> We're using the base ABI
<waj> not even need to link with libunwind
<xender> huh
<waj> now the question would be if Windows has an implementation of these functions
trapped has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<waj> I'm talking about these functions: http://mentorembedded.github.io/cxx-abi/abi-eh.html#base-abi
<waj> in other words, what LLVM provides is a way to generate unwind tables, but it will not unwind the stack for you
trapped has joined #crystal-lang
<xender> Mhm
<waj> Oh... there is an entire section dedicated to Windows: http://llvm.org/docs/ExceptionHandling.html#exception-handling-using-the-windows-runtime
<waj> still, I don't understand why this has something to do with some OS specifics
<waj> is not that we're going to handle C++ exceptions inside Crystal
<xender> No plans for native bindings to C++? :P
elia has quit [Read error: Connection reset by peer]
elia_ has joined #crystal-lang
ponga has joined #crystal-lang
trapped has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Philpax_ has quit [Ping timeout: 248 seconds]
trapped has joined #crystal-lang
<Davy_CC> xender: you mean C++ extensions?
<waj> that's the base ABI. I know... that's so confusing... :(
<Davy_CC> oh... you means Crystal use LLVM error handling to generate unwind tables, and use libunwind for the stack ?
<xender> Davy_CC: I mean interfacing with C++ libraries... If any one is enough sado-masochist to do that
<Davy_CC> sorry I saw the base ABI page
<xender> Davy_CC: But if LLVM is used anyway, maybe by using Clang for paring and compiling C++ that could be actually feasible.
trapped has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<Davy_CC> xender: you mean link with C++ right?
<crystal-gh> [crystal] asterite pushed 2 new commits to master: https://git.io/vgKcW
<crystal-gh> crystal/master 1211585 TSUYUSATO Kitsune: Fix to escape file name
<crystal-gh> crystal/master f286da7 Ary Borenszweig: Merge pull request #2141 from MakeNowJust/patch-2...
<xender> Davy_CC: That's not the worst part, that's just a matter of name mangling and calling conventions.
<xender> Davy_CC: Actually parsing the headers is much worse.
<xender> Davy_CC: And if you want any support for templates... Then you just need a full C++ compiler anyway.
<xender> Davy_CC: There even are header-only libraries for C++ - consisting of only template classess/functions (which have to be places in header file), so the need to have a linking-stage library vanishes altogether.
<Davy_CC> humm
<Davy_CC> is there any language can be compiled with C++ in the way you metioned?
<BlaXpirit> only languages that compile TO c++
<xender> Davy_CC: Maybe Objective-C++. But I don't know how they implement it.
<Davy_CC> supporting C++ template with only headers? (as I know, if there is only header, it couldn't compile templates
<travis-ci> manastech/crystal#f286da7 (master - Merge pull request #2141 from MakeNowJust/patch-2): The build passed. https://travis-ci.org/manastech/crystal/builds/108550027
<xender> Davy_CC: Of course you need something that will instiantiate the templates. But in case of header-only libraries, this will be a code of a program that uses the library.
<Davy_CC> Crystal can link with these libraries, with rewriting the header(or called library binding) in Crystal way
<xender> What do you mean? I already can do it?
<xender> I know it can d C
<xender> *do C
<xender> C++ is an entirely different beast
<Davy_CC> it's the same if you exposed the func in C++
<Davy_CC> but if you want to share classes from C++, it could be hard
<xender> Davy_CC: Regular functions in C++ can have their names overloaded
<xender> You can have 2 or more function with the same name, as long as count or types of their arguments are different
<Davy_CC> yes, your right
<Davy_CC> but if you use `extern "C"`, it could be easier
<xender> And a lots of other stuff, less or more diverging from C
<xender> Yeah, of course, but if you want to interface with any non-trivial C++ library which doesn't already have C-compatible interface, you end up making a wrapper over every class and method.
<xender> Or only over needed ones... Or even place some abstraction in there. So, not a trivial task.
elia_ has quit [Read error: Connection reset by peer]
elia has joined #crystal-lang
elia has quit [Read error: Connection reset by peer]
elia has joined #crystal-lang
elia has quit [Read error: Connection reset by peer]
elia has joined #crystal-lang
elia has quit [Read error: Connection reset by peer]
elia has joined #crystal-lang
endou_ has quit [Ping timeout: 240 seconds]
g3funk is now known as braidn
fowlduck has quit [Remote host closed the connection]
jnylen has joined #crystal-lang
endou has joined #crystal-lang
fowlduck has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
shama has joined #crystal-lang
tomchapin has joined #crystal-lang
pawnbox has joined #crystal-lang
emmanueloga has quit [Ping timeout: 250 seconds]
jwaldrip has quit [Ping timeout: 252 seconds]
ponga has quit [Ping timeout: 240 seconds]
iamstef has quit [Ping timeout: 240 seconds]
x0f has quit [Ping timeout: 252 seconds]
krtv` has quit [Ping timeout: 240 seconds]
ponga has joined #crystal-lang
x0f has joined #crystal-lang
iamstef has joined #crystal-lang
jwaldrip has joined #crystal-lang
kostya has joined #crystal-lang
emmanueloga has joined #crystal-lang
kostya has quit [Quit: Leaving]
krtv` has joined #crystal-lang
elia has quit [Read error: Connection reset by peer]
elia_ has joined #crystal-lang
elia_ has quit [Quit: Computer has gone to sleep.]
trapped has joined #crystal-lang
trapped has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
joshcarter has quit [Ping timeout: 240 seconds]
jeromegn has quit [Ping timeout: 260 seconds]
victor_lowther has quit [Ping timeout: 240 seconds]
jeromegn has joined #crystal-lang
victor_lowther has joined #crystal-lang
joshcarter has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
A124 has quit [Ping timeout: 276 seconds]
A124 has joined #crystal-lang
srenatus has quit [Quit: Connection closed for inactivity]
luislavena has quit [Quit: Leaving]
pawnbox has joined #crystal-lang
ldlework has joined #crystal-lang
<ldlework> Does anyone know if https://github.com/weskinner/crystal-sdl2 is being maintained?
<ldlework> Contemplating a switch over from Nim
pawnbox has quit [Ping timeout: 245 seconds]
<ldlework> Also is there no for-loop?
<BlaXpirit> ldlework, instead of for x in array -> array.each |x| do
<ldlework> oh right a ruby foundation
<BlaXpirit> ldlework, I don't think any SDL bindings are pleasantly usable
<ldlework> doh
<BlaXpirit> not that I have enough knowledge on SDL to assert this
<ldlework> I don't see where iterators or each is described in the crystal docs?
<BlaXpirit> ldlework, you could check http://crystal-lang.org/api/Array.html ctrl+F "each"
<BlaXpirit> and you'd find it in Instance methods inherited from module Iterable
<ldlework> huh I must have been looking at some other documentation
<BlaXpirit> ldlework, well that's like a tutorial/manual
<BlaXpirit> sure, best to start from this tutorial
<ldlework> lol I just want to know how to do someting N times
<ldlework> Do ranges create arrays I can iterate over?
<BlaXpirit> ldlework, (1..n).each do
<ldlework> thanks
<BlaXpirit> this "each" is never mentioned in the tutorial :(
<ldlework> nope
<ldlework> Neither is do syntax...
<ldlework> Seems the tutorial assumes you've used Ruby before I guess.
<BlaXpirit> ldlework, yes, this mindset sometimes pops through
<BlaXpirit> i hate it so much :|
<ldlework> I have no idea how to define the body of that do function
<ldlework> eh fuck this, I'll write my game in another 10 years
<BlaXpirit> ldlework, closest thing to the description of "each" is http://crystal-lang.org/docs/syntax_and_semantics/blocks_and_procs.html - that's the underlying concepts that allow to implement "each"
<BlaXpirit> ldlework, why not read the whole tutorial then check some examples
<ldlework> BlaXpirit: I'm just trying to quickly prove to myself, or not, a simple trivial factory which is apparently impossible in Nim, is well trivial in Crystal.
<BlaXpirit> but yeah, I did have to read ruby docs to get into all this stuff
<ldlework> I find it very hard to write generic extensible library code in Nim
<BlaXpirit> well that's a mouthful
<ldlework> It looks trivial to override the method of a library base-class in Crystal.
<ldlework> Even if that method is generic.
<BlaXpirit> sure
<ldlework> In Nim, the answer is "pass around structures containing closures"
<ldlework> wtf
<BlaXpirit> ldlework, but you gotta check out this stuff https://github.com/BlaXpirit/crsfml
<ldlework> BlaXpirit: ah you're more confident in this binding?
<BlaXpirit> for sure
<ldlework> Lord, I'm tired of porting my game.
greengriminal has joined #crystal-lang
<ldlework> How do I call a method on an instance from inside a different method on that instance?
<ldlework> What is "self" or "this" ?
<BlaXpirit> ldlework, to call a method you write "methodname" or "self.methodname"
<BlaXpirit> don't remember any "this"
<ldlework> BlaXpirit: is "@" the way to refer to attributes/properties of the instance?
<BlaXpirit> ldlework, yes. and they're always private
Philpax_ has joined #crystal-lang
<BlaXpirit> so you publish them by making two methods 'attr()' and 'attr=(value)'
<BlaXpirit> these are like getter/setter
<BlaXpirit> and there are macros to avoid boilerplate
<ldlework> BlaXpirit: what's wrong so far? https://gist.github.com/dustinlacewell/4f453e2ec55b2530b428
pawnbox has joined #crystal-lang
<BlaXpirit> ldlework, typos
<ldlework> heh
<ldlework> oh
<ldlework> BlaXpirit: Error in ./factory.cr:31: undefined method 'getValues' for StaticFactory
<ldlework> oh noes, why doesn't it inherit it from Factory base class?
<BlaXpirit> i have no idea what's going on
<BlaXpirit> there's an "end" missing but if i add it it says there are too many ends
<ldlework> the abstract method needed one too
pawnbox has quit [Ping timeout: 264 seconds]
<BlaXpirit> ldlework, ok here's the initial working version https://carc.in/#/r/s2o
<BlaXpirit> not that you really need these abstract classes. there's duck typing
<ldlework> I just wanna rub it in #nim's face :/
<BlaXpirit> now i'm going offline (IRC stays on though)
<ldlework> thanks for the help BlaXpirit
<ldlework> BlaXpirit: next time you're around, I'm wondering why this version doesn't work? https://gist.github.com/dustinlacewell/aacf4e79ba46a66f8f0b
<ldlework> Or anyone in this channel really...
<BlaXpirit> ldlework, abstract def must not have 'end'
<BlaXpirit> and i forgot the punchline
<ldlework> removing it causes an error
<ldlework> expecting identifier 'end', not 'EOF'
<BlaXpirit> crystal has no Windows support
<BlaXpirit> if that concerns you
<ldlework> ah removing the `do` fixed it kinda
<ldlework> I get `100`, then `1..5` as the output lol
<ldlework> the hell
<ldlework> oh I have to then emit the return value duh
<ldlework> nice it works
<ldlework> BlaXpirit: no windows support yikes
<ldlework> BlaXpirit: like ever?
<BlaXpirit> there are some disorganized efforts
<BlaXpirit> but srsly now, bye
trapped has joined #crystal-lang
greengriminal has quit [Quit: Leaving]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 240 seconds]
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/vgih0
<crystal-gh> crystal/master 0717dfd Ary Borenszweig: Make JSON.mapping and YAML.mapping define instance variables
<travis-ci> manastech/crystal#0717dfd (master - Make JSON.mapping and YAML.mapping define instance variables): The build passed. https://travis-ci.org/manastech/crystal/builds/108663400
pawnbox has joined #crystal-lang
trapped has quit [Quit: Textual IRC Client: www.textualapp.com]
pawnbox has quit [Ping timeout: 252 seconds]
tomchapin has quit [Quit: My Mac has gone to sleep. ZZZzzz…]