<ozra>
Aha. So I guessed right. Done something else right then..
<Kilo`byte>
maybe he means appending contents of one array to another
<Kilo`byte>
ah okay
<ozra>
Does `Array(SomeClass+)` mean any subtype of SomeClass?
<ozra>
else *wrong*. Wow, I think I've slept to little..
<Kilo`byte>
who needs sleep ;)
havenwood has joined #crystal-lang
<jhass>
yes
<ozra>
Kilo`byte: I've slept between 2-4 hours, sometimes not at all for nights, for some years, finally caught up with me X-|
<ozra>
jhass: ok, thanks..
<Kilo`byte>
ic
<Kilo`byte>
just curious, how come?
<ozra>
Kilo`byte: Just working too much + sleep disorders deluxe since birth.. Usual crap ;-)
<Kilo`byte>
ouch :/
<ozra>
Kilo`byte: no point complaining, I've got food every day, running water, no wars :)
<Kilo`byte>
jhass: the output of the crystal compiler is standalone, right?
<Kilo`byte>
as in, no dependency on crystal
Locke23rus has joined #crystal-lang
<jhass>
yeah, just run ldd on the binary to see what it depends on
Ven has joined #crystal-lang
<ozra>
In catch-all inits, is this not possible: ` @capacity :: Int = 0`?
<ozra>
?
<Kilo`byte>
you shouldn't need the :: Int
<Kilo`byte>
the compiler will infer it
<ozra>
I realize in crystal you don't have too, I'm still a bit in C++ mode in the head - but I do like specing the types in "solid code".. Ofc. I could do `@capacity = 0'u8` etc. to pick other types.. I guess that will be verbose enough..
<ozra>
Bombarding with questions here ;) - how do I `@capacity = max @capacity, count`?
<Kilo`byte>
in Ruby that's [@capacity, count].max
<Kilo`byte>
not 100% sure if same in crystal
<ozra>
ok. I'll check the man instead of being lazy ;)
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<Kilo`byte>
the param types are defined by how a function is called
<Kilo`byte>
if you don't call it, it can't infer types
<Kilo`byte>
you then need to explicitly specify them
Ven has joined #crystal-lang
tlifffreenode_ has joined #crystal-lang
tlifffreenode_ is now known as tliff
<ozra>
Hmm... I'm learning by the line here, and am having some more problems, if you'd care to look at some stub code: Kilo`byte
<ozra>
Or anyone else..
<ozra>
jhass: ? ^
<tliff>
okay, I might be doing something really stupid here, but is it possible to monkey patch Float?
<ozra>
Ignore that - I just made a plain stupid thing ;-)
<ozra>
Yeay, working. Sorry for asking presumtiously. I'm just on my toes thinking I'm gonna hit a compiler bug regarding generic inheritance. Well, did not :-D
<tliff>
oh, it is
<jhass>
ozra: just don't ask to ask, come straight with your question and whoever with an answer is around will respond ;)
<Kilo`byte>
by convention you generally use {} for one-liners and do ... end for multiple lines
<ozra>
Kilo`byte: alright.
<ozra>
What about that 'for' above - is it missing completely? I saw it in macros?
<Kilo`byte>
thats intentional
<Kilo`byte>
actually i am not sure if there was a for thingy. but i'd not use it if there was one
<ozra>
Kilo`byte: I just find it clearer then the do and pipes construct...
<Kilo`byte>
this actually originates from functional programming where (which is a great concept)
<Kilo`byte>
s/where /
<Kilo`byte>
it takes a while to get used to, but once you get to that point you don't want back
DeBot has quit [Quit: Crystal IRC]
<Kilo`byte>
which makes me curious, are all those manipulations lazy?
DeBot has joined #crystal-lang
<Kilo`byte>
in ruby they aren't
<ozra>
Kilo`byte: Yeah, I realize that, I enjoy functional too - but when doing imperative, I just want to express things that looks the clearest.. many cases where I would define/use something functionally, I must instead make it a member of (not always very logic) class... Well, in any event - I have coded like that for years in JS etc - and yes - I've gone back! ;-)
<Kilo`byte>
weird. then i don't understand why this isn't working
<ozra>
is there any performance hit to making a reference nilable? Or, I'm guessing, it's just a matter of safety ensuring they must be non-nil by default?
<Kilo`byte>
ozra: you cannot directly use a nilable type
<Kilo`byte>
you need to do a nil check or you get a compile time error
<Kilo`byte>
jhass: uh, can i do debug prints in a spec?
<Kilo`byte>
i don't seem to see any output from them
<ozra>
Kilo`byte: Ok, that's great! I only had to make two instance vars nilable to be able to pass self from initialize().. But they're not ever used unitialized. The constraint should be able to solve in the compiler - since all facts are given at that point. But this works :)
<jhass>
Kilo`byte: uh, I'd expect so
<Kilo`byte>
okay... then this method is not called...
<ozra>
Are there any magic params for blocks or anything? like `it`, when not specifying |some–param|?
ejohnson has quit [Quit: Connection closed for inactivity]
asterite has quit [Quit: Page closed]
<ozra>
asterite: Ah, super cool :) great for one liner situtations like that, I just might live without for anyway :)
waj_ has joined #crystal-lang
waj has quit [Ping timeout: 256 seconds]
waj_ is now known as waj
aemadrid has joined #crystal-lang
veelenga has quit [Quit: Page closed]
ponga has quit []
jtarchie has joined #crystal-lang
<ozra>
Any way of declaring a method with some attribute like @[Flatten] or @[InlineCalls], or a @[AlwaysInline] at specific call sites? (That is, I want to say that all calls in this method should be inlined, instead of saying that it is an inlinable method)
<ozra>
(or preferably at specific call sites)
Ven has quit [Disconnected by services]
Ven_ has joined #crystal-lang
shama has joined #crystal-lang
<waj>
ozra: there isn’t any attribute right now. Do you need to inline even in non-release mode? I wonder why do you actually need this.
<ozra>
waj: No I don't need to in non release. What I want is basically to add a small intro and outro to all defs of subclasses - now done by calling them from a def in the "mother class". Could probably be done by macros too. They might not be considered for inlining because of their size, but the use is just as I said - boilerplate code they all need..
<ozra>
all defs of a specific name that is - not _all_ defs..
<waj>
ok, actually… there IS an attribute: AlwaysInline
<ozra>
right, I'm just trying to avoid it at the sub class implementations, since they will be count less ;-)
<waj>
just add @[AlwaysInline] to your methods and LLVM should do the rest
<waj>
oh… sorry, I just re-read your question
<ozra>
Well, it ain't no biggie - it might even be faster without inlining, but got curious :)
<BlaXpirit>
I don't know Ruby ecosystem at all, and I am not interested in it anyway
<Kilo`byte>
jhass: bad. i'd have expected no less than 0x7D28F28A
<BlaXpirit>
and probably not enough knowledge of both languages, anyway
<Kilo`byte>
although we both probably run 64 bit systems and not 32
<jhass>
okay let me repharse then: webframework <-> http/application server interface & common tools, build tool, template language (that has a non-evaling variant), XML/HTML parser & builder
<jhass>
Kilo`byte: carc.in actually runs on 32bit
<Kilo`byte>
oh okay
<BlaXpirit>
what kind of templating languages does crystal have now?
<jhass>
not sure I get the 0x7D28F28A reference
<jhass>
BlaXpirit: ECR
<Kilo`byte>
can we get haml? xD
<BlaXpirit>
jhass, is that just DSL?
<Kilo`byte>
(would probably depend on the compiler though)
<BlaXpirit>
wait, no
<BlaXpirit>
ECR is like macros
<BlaXpirit>
if i remember
<jhass>
yeah, pretty much
<Kilo`byte>
or alternatively something like phps twig
<BlaXpirit>
so it's compiletime templates
<jhass>
it transforms the code into crystal code building a string
<BlaXpirit>
interesting how that works
<BlaXpirit>
is it possible to make in userland or has to be built into compiler?
<Kilo`byte>
doesn't the compiler expose an API you can use?
<Kilo`byte>
jhass: this is complex. i need to wait until either sudo exists (user aborted) or i need to wait until the child process confirms its launch via the socket (user entered password)
<vifino>
ozra: Yeah, me, but I'm a crystal noob :D
<vifino>
Noob as in, I've never written any projects with crystal :P
<ozra>
vifino: Slightly OT, but what do you think of nanomsg? I haven't tried it yet.
<Kilo`byte>
how'd i get the fd for an IO and also create a new IO from said fd
<vifino>
ozra: nanomsg sounds cool, haven't looked at it too much.
<vifino>
I'm still looking for a pubsub in which both client and server and sub and pub :)
<vifino>
Probably gonna end up with MQTT.
<ozra>
vifino: The notion of a 'better rewrite of ZMQ by a dev from ZMQ' does have a good ring to it ;-) Just don't know how mature it is.. Being in C probably makes it dead simple to jack into in with crystal.
<ozra>
MQTT? I'm gonna google..
<vifino>
ozra: Yeah, sounds neat :P
<vifino>
All bindings/api's for MQTT suck though :v
<vifino>
( Yes, all suck. Every single one. )
<ozra>
vifino: Wtf, that doesn't sound like a good future :-/ But I like that it is first citizen approaching bad bandwidth, shaky connections and energy consumption. That's the reality...
<vifino>
ozra: It itself is glorious, but the interface to it are bleh... :/
<ozra>
vifino: So whip up a binding for Crystal that kicks ass ;-)
<jhass>
Kilo`byte: Signal::CHILD.trap
<Kilo`byte>
oh nice
<vifino>
ozra: Sounds like a plan :)
<ozra>
:)
<jhass>
Kilo`byte: and FileDescriptiorIO.new(io.fd) I guess
<jhass>
or there's also dup somewhere
<vifino>
ozra: Wanna do that together? :P
<Kilo`byte>
yeah, i figured that out after 5 or so mins of reading documentation
<ozra>
vifino: I think I'm a bit to tied up in other coding atm :-/ But I'd love to help out when/where I can! How horrible is the C++ API? (I will need to message rather large data to/from a C++ Qt UI App...)
<vifino>
ozra: Didn't look at the C++ one yet :P
<vifino>
But go google for eclipse paho
<ozra>
vifino: So perhaps my use case is not the ultimate for the bad connection stuff (it will be used 99% on the same machine), but I mean, could use it anyway :)
<Kilo`byte>
jhass: i kinda feel like i gotta work on the process api later
<Kilo`byte>
adding some utilities
<Kilo`byte>
like the ability to launch the process async, but to get a callback called when it exits
<vifino>
ozra: You sadly need a server in the background, because it needs a router, but apart from that, it looks like it isn't too bad of a choice to use MQTT :)
<jhass>
Kilo`byte: yeah sure
<jhass>
Process.run also still doesn't has stderr mapped I think
<ozra>
Aha, its brokered.. Hmm, that makes a difference in my case ofc :-/
<Kilo`byte>
because if everone adds their own sigchld handler... that will get messy
<jhass>
Kilo`byte: oh btw http://carc.in/#/r/580 it's that the playpen kills everything if the parent exits
<Kilo`byte>
oooo ic
shama has joined #crystal-lang
<Kilo`byte>
jhass: Process.spawn(...) do {|event| ...}
<Kilo`byte>
i kinda miss enums with values in crystal
<jhass>
mh?
<Kilo`byte>
(as known from most functional languages)
<Kilo`byte>
enum Stuff
<Kilo`byte>
Something
<Kilo`byte>
SomethingElse(Int32)
<Kilo`byte>
end
<Kilo`byte>
latter enum value can contain an int32 when passed somewhere
<ozra>
vifino: 's like - I've replaced dropbox with decentralized device syncing, torrent style, using syncthing - everythings moving away from centralized solutions ;-)
<jhass>
mmh
<vifino>
ozra: Nice :)
<Kilo`byte>
you can work around that with classes, but its not as nice
<jhass>
but then they're no longer singletons, right?
<Kilo`byte>
class Stuff; end; class Something < Stuff; end; class SomethingElse; <forgot the helper function>; end
<ozra>
vifino: well, I guess I might look at nanomsg anyway.. right now the old implementation I have just use http (because there was a web-interface parallell for a while).. so it's not step number one right now...
<Kilo`byte>
jhass: i am not exactly sure how they are implemented, but you generally would use them like a = Stuff::SomethingElse(42)
<Kilo`byte>
destructuring is another issue, you usually do that with pattern matching (maybe make the value behave like a tuple. that coule work)
<jhass>
well, you could always write a macro to generate yourself some hierarchy of structs I guess :P
<Kilo`byte>
i may actually play with that stuff
<Kilo`byte>
not now though
<Kilo`byte>
i'll actually take a break
<Kilo`byte>
tbh, i just learned about crystal yesterday and its already my favourite language
<Kilo`byte>
xD
bcardiff has joined #crystal-lang
<jhass>
yeah it does that xD
<Kilo`byte>
or was it tuesday, i forgot
<vifino>
I forgot to ask; Is there documentation for `asm` yet? :P
<Kilo`byte>
syntax wise i like scala even more, but that compiles to java bytecode which makes it really bloaty
<ozra>
Kilo`byte: Learned yesterday too, and I get happily surprised all the time, have my gripes, but they're minor compared to the good stuff :)
<Kilo`byte>
i mean, i have been working with ruby for quite some time now
<Kilo`byte>
makes understanding crystal much easier
<jhass>
I have to agree with asterite though that we're at a point where we should be careful with adding/changing syntax/language features too much
<jhass>
there are a lot of people discovering it with diverse backgrounds and having all kind of ideas from everywhere
<jhass>
trying to add them all now wouldn't be wise
<jhass>
we should rather build a community, discover patterns & anti patterns of the language and see where the majorities are/where useful changes are
<Kilo`byte>
yeah
<Kilo`byte>
you can always add on later
<Kilo`byte>
removing is way harder
<jhass>
that is real pain points, not much "it would be nice to have" stuff
<ozra>
jhass: Yes, we are many ;) But I think that's good - there are great parts that would fit from functional territory and others too - the right parts should find a place when consensus is reached.
<Kilo`byte>
yes
<jhass>
I still think I'd like to see 1.0 without all that though, maybe for 2.0
<jhass>
but 1.0 should get what we have so far rock solid first
<Kilo`byte>
syntax wise the lang should be mostly ready for 1.0 - just stdlib and stability stuff i'd say
<ozra>
I think it would be important to shake out some things _before_ 1.0, because at that point their cut in stone..
<Kilo`byte>
although i don't know it very well yet
<jhass>
ozra: ruby 3.0 thinks about adding soft/gradual typing, I'm not sure how much in stone stuff really is ;)
<ozra>
Well, if old code is supposed to be compilable..
<jhass>
I'm not saying to not change stuff if we discover anti patterns before 1.0
asterite has joined #crystal-lang
<ozra>
I mean things like the issue of `id?()` vs `?` for other uses, etc. I'm still too new to have formed opinions about it - I'm still building my minimum case of POC that worked out greatly, now I'm building upon it trying things that may introduce problems and/or teach me more :-)
<jhass>
there's just enough in the stuff that exists already that needs to be worked out, if we keep adding stuff we never reach a stable language
<Kilo`byte>
makes polimorphic code really easy, even if you manually specify types
<asterite>
so we thought there was no need to reinvent the wheel
<willl>
yeah the union types make the crystal type system so much less a pain in the ass compared to go
<vifino>
asterite: Hey there, and thanks :)
<asterite>
willl: really? I thought interfaces were pretty good for that in go
<Kilo`byte>
if you have 3 wrappers for the same function with just different types and the wrapped function also has 3 versions, i only need one wrapper
<Kilo`byte>
as long as the arg count matches
<asterite>
willl: or, said another way, I'd like to know what are the pains in go (so we can improve that, of course)
<willl>
it's super simple, run a few sql commands on a database, but because each query needs a different type, trying to put them all together, you have to resort to interface{}
<willl>
then at that point there is no point to the type system
<vifino>
asterite: What about inline llvm ir? Wouldn't that be better suited? At least you don't have to worry about your target! :D
<willl>
I tried to get them all to have a similar interface to work, but there were other complications, but it's been long enough I forgot exactly why it wouldn't work that way unfortunately.
<asterite>
vifino: crystal code is pretty much inline llvm, most of the time it's a 1 to 1 translation
bcardiff1 has joined #crystal-lang
<asterite>
willl: I see. Yes, interface{} is the main complaint in go, I think
<vifino>
asterite: Sorry, didn't understand that one - I meant something like `asm` but for llvm ir, is that what you mean, or not? o.O
bcardiff has quit [Ping timeout: 264 seconds]
<asterite>
vifino: the problem with that is that we tie ourself to a particular backend... maybe if one day we want to switch to gcc, we can't. But asm is down there everywhere
<vifino>
Hmm...
<vifino>
An undocumented unsupported function for that would be awesome anyhow xD
bcardiff has joined #crystal-lang
<asterite>
Also, if you check llvm's reference ( http://llvm.org/docs/LangRef.html ) we cover almost every instruction. For example 1 + 2 is the add instruction, etc.