<Mercurial_>
vikaton: sorry that should be self.size
<Mercurial_>
the size of the array being entered into the function
<vikaton>
Mercurial_: I'm gonna need more of your code so I can test this
<Mercurial_>
this is for the language
<Mercurial_>
its meant to be implemented in the language
<Mercurial_>
vikaton:
<vikaton>
Mercurial_: a method for Array?
<Mercurial_>
vikaton: yeah
<vikaton>
I got it working with programming concepts I've never used before :D
<vikaton>
now onto the error
<vikaton>
Mercurial_: well to fix your particular issue, it should be
<vikaton>
last_group = self[start, length.to_i32]
<vikaton>
but then another error pops up
<vikaton>
Mercurial_: did you try the .to_i32 method?
<Mercurial_>
yeah i tried it
<Mercurial_>
I get another error too
<vikaton>
mhm
<Mercurial_>
vikaton: no overload matches 'Array((String | Int32 | Char))#<<' with types Array(Int32)
<vikaton>
Mercurial_: you do realize you are pushing the whole array into groups?
<vikaton>
if you want to push arrays in arrays you do
<vikaton>
groups = [] of Array(In32) and son
<vikaton>
so on*
<Mercurial_>
what do you mean?
<Mercurial_>
I don't get how to push arrays into arrays
<vikaton>
Mercurial_: you know how oyu have Array(String | Int32 | Char)
<vikaton>
?
<Mercurial_>
vikaton: yeah
<vikaton>
Mercurial_: and how '<<' pushes to the array?
<vikaton>
well in your code, instead of pushing an Int32, you were pushing an Array(Int32)
<vikaton>
which isnt valid for groups
havenwood has joined #crystal-lang
<vikaton>
so it had to be Array(Array(String) | Array(Int32) | Array(Char))
<vikaton>
for it to accept Arrays
JBat has joined #crystal-lang
JBat has quit [Client Quit]
<Mercurial_>
vikaton: the entire array last_group has to be string/int32/char then?
<vikaton>
Mercurial_: that's what you set it as
<vikaton>
yes
<Mercurial_>
vikaton: I'm still a bit new with certain parts of Crystal's syntax, what would be the best way to declare the array as that while still slicing it from start to length?
<vikaton>
uhh not sure what you mean there
<Mercurial_>
if the last_group array has to be string/int32/char, how would I go about doing that?
dideler has quit [Remote host closed the connection]
unshadow has quit [Ping timeout: 246 seconds]
unshadow has joined #crystal-lang
mdz_ has joined #crystal-lang
<unshadow>
Looking at Ruby's io.eof?, http://ruby-doc.org/core-2.2.2/IO.html#method-i-eof , I see they are using rb_io_eof function, is there something like that in LibC or this is something that should be developed from 0 ?
<strcmp1>
spanish, translates as "nothing" although im irish, dont know spanish properly, & have no connection to spain.
<unshadow>
hahah
<unshadow>
I'm getting some exception, and I'm trying to see why, but it seems doing rescue e : Exception and then p e just produces this: #<Exception:0xeb7a20 @message="read_nonblock: read nothing", @cause=nil, @backtrace=["*raise<String>:NoReturn +70 [93]", "~fun_literal_12 +340 [93]", "~fun_literal_3 +33 [93]", "co_exit +75 [93]", "__start_context +0 [93]"]>
<unshadow>
how do I catch this specific error ?
<strcmp1>
that looks like a crystal bug to me, but i guess it'd be an IOError from the message.
<unshadow>
or does the :0xeb7a20 part is some kind of an identifier ?
<strcmp1>
that's just the object_id (in ruby anyways)
BlaXpirit has quit [Remote host closed the connection]
BlaXpirit has joined #crystal-lang
Ven has joined #crystal-lang
NeverDie has joined #crystal-lang
rpitt has quit [Ping timeout: 255 seconds]
<unshadow>
How should I use this : TCPSocket#read(slice : Slice(UInt8)) ?
<unshadow>
let me phrase better
<unshadow>
I used socket.read(1024), it was pointet out to me that it's better to use read(s: Slice(UInt8)) which returns the number of bytes read
<unshadow>
doing socket.read(s: Slice(UInt8)) returns an error
<unshadow>
btw, ruby has an IO.pending? check that returns number of pending bytes, using something like that it's easier to make a better read loop, also .eof? and .closed? will be really cool to have :)
<datanoise>
well, yes. it is a bit verbose. what would be a better API?
<jhass>
that's the tricky part I guess
<jhass>
would it be too bad to switch the default contract to up to?
<jhass>
get a slice back and you have to check it's .size
<datanoise>
the problem with allocation and error reporting. the current API doesn't allocate and reports errors at the same time without using exceptions...
<unshadow>
For me (a dumb user) the easiest way is less converts, if socket.read() expects a UInt8 slice, why wont do that inside the read method and allow me to pass a Int32 like every other language out there ?
<datanoise>
yes, but all of them must use exceptions to indicate IO errors. that's a performace killer
rpitt has joined #crystal-lang
NeverDie has joined #crystal-lang
<crystal-gh>
[crystal] wmoxam opened pull request #761: Adds %, modulo & remainder to Float (master...add-float-modulo-support) http://git.io/vI48H
havenwood has joined #crystal-lang
<unshadow>
datanoise: but IO works almost entirely using EOFErrors, WAITREAD, WAITWRITE etc... for non_blocking modes, there is not too much to do I think
<datanoise>
unshadow: i don't mind helper methods for common tasks, ppl just need to know the trade-offs.
<datanoise>
unshadow: calling .read(min: size) always allocates and raises exceptions which should not be your go-to method for working with IO
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<unshadow>
datanoise: what kind of exceptions ? logicly read(min) mould maybe raise EOFError, and WAITREAD, also always "wouldblock" becuase we are working in a non-blocking mode, the question is would you handle those inside the helper method or outside of it ?
bcardiff has joined #crystal-lang
asterite has joined #crystal-lang
<datanoise>
unshadow: generic read method doesn't know how to handle your IO errors. there are much more errors that it seems there are: http://linux.die.net/man/3/read
<asterite>
jhass: o/ I have some questions for you :-)
<jhass>
o/
<asterite>
In 2048.cr, if you change read_nonblock to read, does it still work?
<asterite>
I tried it in mac and an ubuntu vm and it works for me
<jhass>
back when I wrote it, it didn't
<jhass>
let me try again
<asterite>
I think back then we didn't have read(length), but I'm not sure
<jhass>
it breaks quitting with escape
<jhass>
mh, well, that seems to be broken with nonblock too
rpitt has quit [Ping timeout: 264 seconds]
<jhass>
but I remember that it worked with my original _nonblock
<asterite>
Yes, it's because I had to change it after we made the swap to non-blocking IO
<asterite>
unshadow: it's what datanoise says, read(1024) tries to read all 1024 bytes and blocks otherwise
<asterite>
for a loop that reads and prints you should use a static array... it's low level, but it's the only way to get good performance
NeverDie has joined #crystal-lang
bombless has joined #crystal-lang
rpitt has quit [Ping timeout: 272 seconds]
bcardiff has quit [Quit: Leaving.]
<unshadow>
asterite: This part is fine, right now thanks to datanoise the loop reads and behaves as it should, my issue now is that it seems to read untill it stops, I'm not sure if it becuase of spawn? (as in the spawned fiber is sleeping until the main thread does the gets from user) or maybe it's just something else that makes read behave differently
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<unshadow>
btw, in "read untill it stops" I mean it reads, and then it wont read anymore, even though there is more data to read
asterite has quit [Ping timeout: 246 seconds]
<datanoise>
unshadow: read should always return data when available. do you have an example where it doesn't?
<crystal-gh>
[crystal] asterite pushed 2 new commits to master: http://git.io/vIBTt
<unshadow>
datanoise: yeha, you can use my code from here: https://github.com/bararchy/aeon-client/ check out how the read behaves v.s how a simple telnet to the same server and port does .
mdz_ has quit [Ping timeout: 265 seconds]
<datanoise>
unshadow: your autoreader reads first 4096 bytes and then quits
<datanoise>
unshadow: you should use loop/while i believe
<crystal-gh>
[crystal] asterite pushed 1 new commit to master: http://git.io/vIBqz
<crystal-gh>
crystal/master 782f499 Ary Borenszweig: HTTP::LogHandler: show elapsed time
<unshadow>
datanoise: it was inside a while true, loop do, while connection, until the_end_of_days...
<unshadow>
datanoise: I changed it back to loop do on the git now, still same issue, I dont get all the data until a Ctrl + C is pressed and the program exits
<unshadow>
(i'll follow on the IRC logs, need to disconnect for a hour)
unshadow has quit [Quit: leaving]
bcardiff has joined #crystal-lang
c0r5um has quit [Remote host closed the connection]
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
vikaton has quit [Quit: Connection closed for inactivity]
<asbradbury>
am I correct in thinking Crystal will do no automat type coercion for numbers? e.g. allowing you to pass an Int32 instead of an Int64?
asterite has joined #crystal-lang
<asterite>
asbradbury: correct, there's no type coercion
<asbradbury>
asterite: and in the example you posted on the bugtracker from FileUtils, I assume the motivation for `buf1 :: UInt8[1024]` is to allocate a static array without initialising it, as you would with `buf1 = StaticArray(Uint8, 1024).new(0.to_u8)`. That, and it's shorter :)
<asterite>
Yes. I actually don't know which one I prefer, ":" or "::" :-)
<asterite>
I know for sure that we tried with ":" first and then switched to "::"
<asbradbury>
yeah, I can kind of see the argument that :: isn't the same thing. Just thought I'd share my first impression as someone new to the language
<asbradbury>
I'm too used to :: being cons
<asterite>
in lisp?
<asbradbury>
standard ML
<asbradbury>
or ocaml
<asterite>
In any case, "::" isn't used frequently. I can find it 51 times in the whole repo
<asterite>
but don't close the issue, I'd like to know others' opinion on this
<asbradbury>
that's a good point. I'm used to having type annotations all over the place, while it seems normal crystal style allows you to very effectively avoid them in most places
<bombless>
github issue?
<asbradbury>
you could even argue for something like alloc(TYPE_EXPR) or unsafe_alloc(TYPE_EXPR). It doesn't have the same effect as :: but would probably be usable in most of those cases, and would make it clearer that this is potentially unsafe
<asbradbury>
e.g. buf1 = alloc(UInt8[1024]). It would be in the same class as sizeof() and instance_sizeof(), but I can also see why you'd want to minimise these keywords
NeverDie has quit [Quit: I'm off to sleep. ZZZzzz…]
<izzol>
so I was expecting it will create a new file as well :P
<izzol>
or soemthing.
<jhass>
ah, you can get the binary with crystal build hello.cr
<izzol>
ok
<izzol>
now works :-)
<izzol>
cool.
<izzol>
like a go.
<jhass>
a gotcha right on (not that it makes any difference for a hello world sample), to get a fully optimized binary the invocation is crystal build --release hello.cr
<jhass>
use that e.g. for benchmarks
<ddfreyne>
Is there a reason for not beign able to specify the return type of a function/method?
<ddfreyne>
I'd like to let a function return an Enumerable rather than Array, because I don’t want to guarantee for the future that the return value will be ordered in a certain way.
<jhass>
you can actually as of 0.7.2 or 0.7.3, I don't remember
<ddfreyne>
Hm, that’s a little annoying. I guess it is useful when you want to verify that the body of the function *does* return what you expect.
<jhass>
well, I'd say crystal still embraces duck typing and that's a good thing
<ddfreyne>
jhass: It is useful for writing libraries, because with that approach you can prevent implementation details from leaking
<ddfreyne>
"If it compiles, it wil work" no longer holds true without it
<ddfreyne>
(Admittedly, it's the same in Ruby.)
<jhass>
I don't find it very likely though that you leak an object with the same API but a different contract
<ddfreyne>
jhass: Replace Array in an internal method with Set, and code will break if the consumer relies on it being an Array (i.e. responds to #[])
<jhass>
it won't compile then
<ddfreyne>
It will at first, but not after the upgrade
<jhass>
yeah
<jhass>
that's what compile time duck typing does
<ddfreyne>
I argue that it shouldn't have compiled in the first place, because the API you expose (Enumerable rather than Array) will have prevented that.
<jhass>
I think what you specify in the restriction will appear in the docs
<jhass>
so the consumer would rely on undocumented behavior
<ddfreyne>
Doesn't it make sense to let the typecheck fail, then?
Codcore has joined #crystal-lang
<jhass>
I guess, I won't be using that only if I have to hint the compiler anyway
<ddfreyne>
(In the original example, where the consuming code assumes an Array instead of an Enumerable)
<jhass>
*will
<asbradbury>
how does crystal handle breaking changes to the compiler. e.g. if a change in 0.7.4 means that 0.7.3 can't compile the newer compiler? Rust has stageN annotations as I recall
<ddfreyne>
jhass: It'd be mainly useful for libraries.
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
asterite has joined #crystal-lang
<asterite>
ddfreyne: but what's the contract for Enumerable?
<asterite>
asbradbury: what's a breaking change to the compiler?
Ven has joined #crystal-lang
<asbradbury>
asterite: anything that would mean the previous version couldn't compile the new one
<ddfreyne>
asterite: Not sure what you mean :(
<ddfreyne>
I also suppose that what I’m interested in is interfaces, not necessarily modules (like Enumerable).
<asterite>
asbradbury: what's wrong with that? You use version A to compile A + 1, if A doesn't compile A + 2 it's not a problem
<asterite>
ddfreyne: but Enumerable can be reopened and changed, so there isn't really an interface
<asterite>
But yes, I understand the point about interfaces... we don't have them right now, though we might have them in the future
<asbradbury>
asterite: ok, so you accept that sometimes people might need to grab a newer binary build or else build their way through a couple of commits
<asterite>
ddfreyne: you can however make a dummy struct that wraps your value and only provides the methods you want clients to use, and that doesn't have any performance impact
<asterite>
asbradbury: We don't commit things that don't compile with the latest compiler. Maybe I'm not understanding the problem
<asterite>
asbradbury: Oh, maybe I understand now
<asterite>
We run `make clean crystal spec`. That compiles a compiler and with it runs the specs (which exercise the compiler)
<asterite>
so that makes sure that the next compiler and compile itself and nothing breaks
<asterite>
But again, not sure that's your worry
<asbradbury>
asterite: take the suggested change that octal be prefixed with 0o rather than just o. I was looking at it for a simple first patch. 1) add support for parsing 0o, 2) replace all existing octal constants in the codebase with 0o, 3) drop support for 0 (and give an error indicating the syntax change)
<asbradbury>
somebody who does a git pull and ends up with something that contains all those commits, won't be able to build using their older compiler
<asterite>
Oh. We would do 1 first, then make a release. Then we would do 2 and 3.
<asbradbury>
got it, was just wondering if there was any system for handling this between releases.
<asbradbury>
thanks
<asterite>
So we are at 0.7.3, say we do 1 for 0.7.4. If somebody wants to compile code after the 0.7.4 tag, they will need 0.7.4, 0.7.3 might not compile it anymore
<asterite>
Also, if you do 1, 2 and 3 at the same time, there won't be any compiler out there to compile those changes, as none of them support the 0o syntax
<asterite>
so you won't be able to push that pull request :)
<asterite>
datanoise: no worries, I just fixed it, I'll push right away
<asterite>
thanks for reporting it :)
<crystal-gh>
[crystal] asterite pushed 1 new commit to master: http://git.io/vIR1L
<crystal-gh>
crystal/master 32bf333 Ary Borenszweig: Fixed a bug that was mentiond in #759
<datanoise>
np :)
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
zipR4ND has joined #crystal-lang
<zipR4ND>
hey all, is there some kind of a debug macro in crystal that prints out the expression-string and then its value to the console?
<wuehlmaus>
colleagues of mine said that it was likely
<wuehlmaus>
[because of clang and the involvement of its author]
<crystal-gh>
[crystal] asb opened pull request #764: add support for octal numbers with the 0o prefix (master...add_octal_0x) http://git.io/vI0MZ
<crystal-gh>
[crystal] barca opened pull request #765: grammar (gh-pages...gh-pages) http://git.io/vI0Dt
bcardiff1 has quit [Quit: Leaving.]
<asbradbury>
building all_spec with --release takes a *long* time. 19mins and counting
me has joined #crystal-lang
me is now known as Guest77258
asterite has joined #crystal-lang
<asterite>
asbradbury: there's no need to compile specs in release mode
<jhass>
hehe, you're probably the first one doing it :P
<asbradbury>
asterite: I know there's no need, doesn't mean I'm not going to try it :)
<asterite>
:-D
<asbradbury>
I was interested in seeing the typecheck time, so added support to the Makefile for passing FLAGS to the specs build. Then I figured I might as well try a release mode build
<asterite>
I think I tried that too but gave up on waiting
<willl>
I actually gave a try at having spec always be in release to see if it would make specs faster, but waited a few minutes and gave up
<jhass>
I'm op in #ruby if that means anything... ;)
<jhass>
asterite: bcardiff I'll remove your +O flag (auto op on join) since on freenode it's considered bad attitude to permanently display authority ;)
<asterite>
Sure
<jhass>
while we're at it, shall we decide on one official logger bot?
<asbradbury>
all the cool kids are using botbot.me
<jhass>
well, we already have two here running for a while and got some history in them. _whitelogger is widely used and trusted
<asbradbury>
yes, _whitelogger works great
<jhass>
though if asterite & waj want to keep http://irclog.crystal-lang.org/ running that's fine with me too, it's the same software after all
<jhass>
I just find having both a bit redundant :)
<waj>
I’m keeping the irclogger running just in case we want to migrate to something else, I already have all the history in the db
<waj>
maybe to something written in crystal? :)
<waj>
botbot.me crashes a lot to me, and the search is really slow
<jhass>
you still want to keep _whitelogger as "official" though?
waterlink has joined #crystal-lang
<waj>
I just didn’t think about it
<waterlink>
Is `with self yield` works currently? Am I right, that passed block will be executed in context of `self` and have access to its methods?
<jhass>
waterlink: yes, though it won't work for captured blocks and Procs
<waterlink>
what do you mean by captured?
<waterlink>
`&blk` ?
<jhass>
yeah
<waterlink>
hm, any reason why ?
<jhass>
I think it's something with them getting converted to function and not being able to attach different contexts to that functions or something
<waterlink>
even without `&blk` and with simple yield, I cannot make it see the method..
<jhass>
the compiler would need to trace the particular Proc instances and generate different functions for each with call
<jhass>
>> class Foo; def foo; puts "hi"; end; def me; with self yield; end; end; Foo.new.me { foo }
<flaviu>
Ah, I see. I'd also like to suggest moving irclog.crystal-lang.org to crystal-lang.org/irclog/.
<flaviu>
Wildcard SSL certs can get expensive.
<BlaXpirit>
just use whitequark
<asbradbury>
letsencrypt.org will hopefully solve the ssl cert problem
<jhass>
^
<jhass>
still wish DANE would solve it instead
<flaviu>
I'm not sure if Let's Encrypt will provide wildcard certs.
<jhass>
they won't
<jhass>
but you'll be able to script deployment
<jhass>
without human interaction
<jhass>
so that's actually better than wildcard
<jhass>
since you can revoke individual subs
<flaviu>
Ok, sounds good then.
<jhass>
still, DANE would potentially require no external interaction at all after DNSSEC was set up
<jhass>
I'm still heavily disappointed that mozilla has chosen to invest in letsencrypt instead of getting DANE support first
<asbradbury>
letsencrypt seems the pragmatic next step, given the massive lead time that would be involved in waiting for most users to have access to a browser supporting DANE
havenn has joined #crystal-lang
<jhass>
it's only browser support that's lacking though, new gtlds are all required to support DNSSEC and the relevant ccTLDs already do
<jhass>
letsencrypt is removing a lot of pain out of the inherently flawed CA system, delaying its deprecation
<jhass>
the best strategy of course would be to do both with emphasis on DANE and letsencrypt as a migration technology
havenwood has quit [Ping timeout: 276 seconds]
havenn is now known as havenwood
asterite has quit [Quit: Leaving.]
BlaXpirit has quit [Quit: Quit Konversation]
bhishma has joined #crystal-lang
zipR4ND has quit [Ping timeout: 264 seconds]
mdz_ has joined #crystal-lang
mdz_ has quit [Remote host closed the connection]
bhishma has quit [Quit: Page closed]
mdz_ has joined #crystal-lang
mdz_ has quit [Remote host closed the connection]
mdz_ has joined #crystal-lang
waj has quit [Quit: waj]
mdz_ has quit [Remote host closed the connection]
bcardiff has quit [Quit: Leaving.]
bcardiff has joined #crystal-lang
bcardiff has quit [Client Quit]
datanois1 has quit [Ping timeout: 255 seconds]
Guest77258 has quit [Remote host closed the connection]
me has joined #crystal-lang
me is now known as Guest72831
wmoxam has quit [Ping timeout: 245 seconds]
Guest72831 has quit [Remote host closed the connection]
wmoxam has joined #crystal-lang
waj has joined #crystal-lang
flaviu has quit [Read error: Connection reset by peer]