ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.23.1 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
alex`` has joined #crystal-lang
<FromGitter> <bew> @paulcsmith well there was no output (and no errors) because you weren't calling the macro ^^ https://play.crystal-lang.org/#/r/38y2
<FromGitter> <faustinoaq> Interesting post ^^
DTZUZO has quit [Ping timeout: 240 seconds]
<FromGitter> <faustinoaq> Python & Elixir => Go
aroaminggeek has left #crystal-lang ["Textual IRC Client: www.textualapp.com"]
DTZUZO has joined #crystal-lang
<FromGitter> <faustinoaq> Crystal already beats many advantages and disadvantages of Go, I think we just need a stable version for crystal :-)
<FromGitter> <elorest> Yeah.
<FromGitter> <faustinoaq> I'm wondering What big companies doesn't have their own programming language yet? ⏎ ⏎ Microsoft: TypeScript, C# and VB ⏎ Google: Go, Dart, Kotlin (baked) ⏎ Oracle: Java ... [https://gitter.im/crystal-lang/crystal?at=5a346a4fffa3e3791942799c]
<Vexatoast> Wasn't Kotlin done by JetBrains?
<FromGitter> <faustinoaq> Yeah, but now is an official language for Android Studio by Google
<Vexatoast> Doesn't make it a language by Google
<Vexatoast> That's like saying Java is :P
<FromGitter> <faustinoaq> Oh, that make sense +1
<FromGitter> <faustinoaq> Perhaps someday Tesla or SpaceX could dare to try Crystal :)
alex`` has quit [Ping timeout: 265 seconds]
mbarbar has joined #crystal-lang
<jsn-> o_O seriously? there is Time#-(Int), but there's no Time#+(Int)??
<Papierkorb> that #-(Int) should be removed, there's no need for it
<Papierkorb> What is int in? seconds? days? milliseconds?
<Papierkorb> Just use one of the various Int# time span methods, like #seconds
<jsn-> well yeah, that's handy, but having all those methods on ints feels somewhat railsy
<Papierkorb> It makes it readable, understandable, removes clutter all around
<Papierkorb> And makes it non-ambigous
<Papierkorb> `Time.now + 5` five what? apples?
davic has joined #crystal-lang
<Papierkorb> `Time.now + 5.seconds` Everyone understands that, including those who have never even used those functions before. Can't get better than that
<Papierkorb> `TIMEOUT = 1000` timeout in what? msec? sec? Who knows! `TIMEOUT_MSEC = 1000` this is clutter and crap. `TIMEOUT = 500.milliseconds` configurable, no clumsy name, so much better.
<jsn-> sure, but having it documented in Int part of the docs is not very intuitive
aroaminggeek has joined #crystal-lang
aroaminggeek is now known as aroaminggeek[awa
aroaminggeek[awa is now known as aroaminggeek
aroaminggeek is now known as aroaminggeek[awa
aroaminggeek[awa is now known as aroaminggeek
aroaminggeek is now known as aroaminggeek[awa
aroaminggeek[awa is now known as aroaminggeek
aroaminggeek is now known as aroaminggeek[awa
aroaminggeek[awa is now known as aroaminggeek
astronavt has joined #crystal-lang
aroaminggeek is now known as aroaminggeek[awa
astronavt has quit [Remote host closed the connection]
mbarbar has quit [Ping timeout: 265 seconds]
aroaminggeek[awa is now known as aroaminggeek
<FromGitter> <codenoid> helo
rohitpaulk has joined #crystal-lang
mbarbar has joined #crystal-lang
alex`` has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 256 seconds]
claudiuinberlin has joined #crystal-lang
aroaminggeek is now known as aroaminggeek[awa
rohitpaulk has joined #crystal-lang
aroaminggeek[awa is now known as aroaminggeek
aroaminggeek is now known as aroaminggeek[awa
aroaminggeek[awa is now known as aroaminggeek
aroaminggeek is now known as aroaminggeek[awa
rohitpaulk has quit [Ping timeout: 264 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <unreadable> hi
<FromGitter> <unreadable> even Huawei has its own secret language
<FromGitter> <unreadable> but python is better than go in some cases..numpy for example its based on highly optimized fortran and c++ code
<FromGitter> <unreadable> and dead simple to learn/use
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <faustinoaq> @unreadable Huawei uses C++ and VisualStudio mainly (https://www.youtube.com/watch?v=ra3Pd8KoVOw)
<FromGitter> <MrSorcus> Hi. How to run multiple instance of http server on different addresses? Thanks.
<FromGitter> <faustinoaq> @MrSorcus Maybe creating multiple instances at different IP addresses : ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5a34f1bfffa3e379194476a6]
DTZUZO has quit [Ping timeout: 248 seconds]
aroaminggeek[awa is now known as aroaminggeek
aroaminggeek is now known as aroaminggeek[awa
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <MrSorcus> > @MrSorcus Maybe creating multiple instances at different IP addresses : ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Oh, you right. I did something like that, but without "sleep". ... [https://gitter.im/crystal-lang/crystal?at=5a34f86ca2be466828ab4bca]
rohitpaulk has joined #crystal-lang
<FromGitter> <unreadable> c++ expres.js like framework
<FromGitter> <unreadable> kinda impressed how easy was to set it up oO
<oprypin> unreadable, it's ok if you switch to a different programming language every day, but we don't care
<FromGitter> <unreadable> I'm pretty much on cgo/node.js, but I like know st
<FromGitter> <unreadable> I like knowing other stuffs
<FromGitter> <unreadable> *
<oprypin> ok this isn't a channel about other stuffs
<FromGitter> <unreadable> Ikr, But what makes you think I'M switching programming languages everyday?
<Papierkorb> "Whoa Java .. Whoa C++ .. Whoa $LANG"
_whitelogger has joined #crystal-lang
<RX14> i personally don't mind off-topic as long as the channel isn't busy
<RX14> but if other people do, then I will mind it
<RX14> keep it interesting and tangentially related if you do go off topic
<Papierkorb> ^
<RX14> starting at crystal and migrating off-topic is almost universally accepted
Zaskroniec has joined #crystal-lang
Zaskroniec has left #crystal-lang [#crystal-lang]
aroaminggeek[awa has quit [Ping timeout: 248 seconds]
<FromGitter> <LuckyChicken91_twitter> im trying right now to create a little textbased minesweeper in crystal and i have this code right now: https://carc.in/#/r/390v/edit ⏎ can someone read the comment i wrote in line 43 and can me tell why? and does anyone have suggestions?
<oprypin> `@board.unshift("NEWLINE")` "why is there a newline at the beginning"
<oprypin> also seems like the worst way to represent the board internally
<FromGitter> <LuckyChicken91_twitter> no i mean if you look at the generate code then its weird that theres a newline at the first position of the array
<FromGitter> <LuckyChicken91_twitter> because actually im running the width.times code which generates one line before the newline code
<oprypin> i am looking at the generate code and suggesting you to check what `unshift` means
<FromGitter> <LuckyChicken91_twitter> ooh! i got it! thank you. Im probably adding the string to the array at the wrong position
<FromGitter> <LuckyChicken91_twitter> ok reversing fixed it. thank you very much
daemonwrangler_ has quit [Ping timeout: 255 seconds]
alex`` has quit [Ping timeout: 272 seconds]
DTZUZO has joined #crystal-lang
alex`` has joined #crystal-lang
ubuntu has joined #crystal-lang
<FromGitter> <simenge> I'm getting an extremely odd error. I'm defining a function inside a module, and literally using that function on the next line inside that module. But I get the error message "undefined method", even though it was working fine until I made changes elsewhere in the code
ubuntu is now known as Guest83243
aroaminggeek has joined #crystal-lang
aroaminggeek has quit [Ping timeout: 268 seconds]
aroaminggeek has joined #crystal-lang
<FromGitter> <simenge> Ok, I think I figured it out. Apparently the "crystal" command doesn't always recompile imported modules even if they have been changed... At least on Windows
aroaminggeek is now known as aroaminggeek[awa
Guest83243 has quit [Ping timeout: 260 seconds]
<oprypin> wut
mbarbar has quit [Ping timeout: 248 seconds]
<crystal-gh> [crystal] Sija opened pull request #5390: BigDecimal enhancements (master...bigdecimal-tweaks) https://git.io/vbKvk
<FromGitter> <simenge> wut?
<RX14> @simenge because we don't have: modules, windows support, or any caching
<RX14> so what you said makes very little sense
<FromGitter> <simenge> Crystal works on "Bash on Ubuntu on Windows", and fairly well at that, although I would obviously prefer native Windows support. I have no idea what you mean by "we don't have modules" - what the hell is the "module" keyword for then? That is what I meant. I am coming from a Ruby background and from my experience Ruby and Crystal modules work the same, serving the dual purposes of namespacing and mixins
<FromGitter> <simenge> Perhaps the bug was related to the bash emulation stuff, but the other things you said make no sense to me
<RX14> @simenge we don't have "code modules" which are compiled seperately, sorry for the confusion
rohitpaulk has quit [Remote host closed the connection]
<FromGitter> <simenge> Oh ok, I see.
<FromGitter> <simenge> Anyway, I'm really missing full algebraic sum types with pattern matching here. So many casts, everywhere, could be avoided with them
<FromGitter> <simenge> I'm writing a simplistic lisp to learn crystal so this type of thing comes up A LOT
<RX14> well you're probably "using crystal wrong" then
<RX14> crystal is object oriented not functional
<RX14> sure you can do functional things like maps and folds with it but when I write crystal I rarely reach for agebraic datatypes
<RX14> and I havent written a .as cast in months
<RX14> @simenge if you give me a piece of code hopefully I can tidy it up for you
<FromGitter> <marksiemers> @simenge - I would be curious to see the code as well, and @RX14's input on it.
<FromGitter> <simenge> Crystal has inherited a ton of functional features from Ruby, they are just easier to use in Ruby due to the lack of static typing. Plenty of multi-paradigm languages exist out there. You are probably right that I'm "using it wrong" since I'm still learning it, but still, pattern matching is insanely useful and there's no reason why it can't be in an OO language
<RX14> there's been a lot of discussion about pattern matching
<RX14> but I haven't seen a case where it's actually very useful yet
<FromGitter> <simenge> I will post a code sample. Note that it is not intended to be optimized or anything like that. It's just a learning project
<RX14> i thought I would but it turns out case statements can handle it pretty well
<RX14> @simenge that undefined method error is weird though
<RX14> perhaps you just forgot to run the compiler?
<FromGitter> <simenge> case statements can't destructure complex data structures cleanly, nor do they help at all with type inference
<RX14> they do help with type inference
<RX14> are you using an instance var perhaps?
<RX14> or a method call by accident?
<RX14> instance or class vars cannot be restricted without being assigned to local vars because they might be changed by another thread
<RX14> local vars can
<RX14> and obviously a method can't have flow typing applied either
<RX14> since it can return something different each call
<FromGitter> <simenge> This is the WIP version of my naive lisp written to learn crystal: https://gist.github.com/simenge/bdf5415c4051ef1050709f0e45208bdf
<FromGitter> <simenge> I would much rather prefer Lisp::Object to be a tagged union where I don't have to constantly cast the @value property after I already validated its tag
<RX14> it is a tagged union
<RX14> oh sorry
<RX14> i was looking at LVal
<RX14> @simenge you seem to be using unneccesary casts though
<RX14> like on line 20
<RX14> to_s.as(String) ??
<RX14> to_s always returns a string
<RX14> unless you've implemented it incorrectly somewhere
<FromGitter> <simenge> Crystal's type inference of block return values leaves something to be desired
<RX14> also in crystal you always override def to_s(io) since a lot of methods will call the version that takes IO
<FromGitter> <simenge> perhaps I overdid it in this instance, but there are instances where you have to do stuff like that
<RX14> @simenge i doubt it
<Papierkorb> That #to_s on line 19 is wrong, it should be to_s(io)
<FromGitter> <marksiemers> On line 45, could this work? ⏎ ⏎ ```when value = Tag::List ⏎ value.to_s``` ⏎ ⏎ The local variable wouldn't be a union at that point, it would just be a `Tag::List` ... [https://gitter.im/crystal-lang/crystal?at=5a3549ce540c78242dd182bd]
<RX14> @simenge your Lisp::Object#to_s returns LVal
<RX14> since you return @value which is a LVal
<RX14> thats why you override to to_s(io) version
<RX14> its impossible to make to_s not return a string
<FromGitter> <marksiemers> Oh sorry, ignore that code
<RX14> also because performance but it's nicer too
<FromGitter> <simenge> RX14, the code will not compile without the "unnecessary" cast. Error: "can't infer block return type, try to cast the block body with `as`"
<FromGitter> <simenge> also I only ever return @value when I have already verified by its tag that it's a string
<RX14> @simenge it appears you need to internalize that you must assign instance vars to local vars for thread safety before restricting it's type
<Papierkorb> simenge, might be an artifact of you overriding #to_s the wrong way.
<RX14> @simenge but the compiler cannot prove that can it
<FromGitter> <sam0x17> if someone had to estimate when windows support will be working (not necessarily released, just in master somewhere), would that be like 2 months, 6 months, a year, 1.5 years? best guess?
<RX14> it has no knowledge of the relaionship between tag and value
<RX14> and even if it did it's an instance var
<RX14> compilers cannot read minds yet
<FromGitter> <simenge> see, this is where pattern matching would be useful
<RX14> no, it wouldn't help here
<RX14> you don't need Lisp::Object
<RX14> crystal unions are already tagged
<Papierkorb> simenge, Fix your #to_s methods.
<RX14> havent had a can't infer return type of block for ages though
<RX14> i forget when it happens
<RX14> @list.map(&.to_s).join(' ') should absolutely compile though
<Papierkorb> Also had it ... ages ago. Don't remember why, iirc it was in a snippet like Array.new(123){ HTTP::Client.new(..) } or something
<RX14> seems to happen when the block body is typed as void somehow
<FromGitter> <simenge> @list.map(&.to_s).join(' ') fails with the same error
<Papierkorb> simenge, have you fixed your to_s methods yet?
<FromGitter> <simenge> how so? what is there to fix?
<RX14> we just told you
<RX14> about 3 times
<RX14> they dont return string
<Papierkorb> Including on how at least once or twice
<FromGitter> <simenge> Every single variant returns a string. But apparently the compiler can't figure that out without explicit casts. If I could use pattern matching, then this would not be a problem
<Papierkorb> You didn't read what we wrote now did you?
<RX14> how would pattern matching solve the to_s on Lisp::Object?
<RX14> you check @tag
<RX14> and always return @value
<RX14> how can you possibly expect the compiler to infer that the type of @value depends on @tag
<RX14> you can't
<RX14> because you can't express that dependency to the compiler given how you wrote it
<RX14> if you use a union where each value of @tag is a type in the union you can express that
<FromGitter> <simenge> No, but I could express that relationship in haskell, scala or ocaml
<RX14> as in: Lisp::Object is better as a union
<RX14> @simenge how?
<RX14> you can't make something at the type level depend on something at the runtime level
<RX14> that doesn't make sense in a statically typed language
<FromGitter> <simenge> Here is some pseudo-haskell: https://gist.github.com/simenge/8809d7be57b791f93cdf03474d62589c
<FromGitter> <simenge> Probably not entirely correct, but close enough as pseudocode
<Papierkorb> Oh there you use language features
<RX14> ah but now you've expressed that relationship at the type level
<RX14> as a language feature
<RX14> (hint: we have that, they're called unions)
<Papierkorb> RX14 already advised you how to do the same using Crystal langauge features
<Papierkorb> Manually writing Tagged Unions? Cr does that for you. You can also use `case`, with almost the same syntax as in .hs, to do the same in Crystal
<FromGitter> <simenge> It's a class. If I want a method on it, I have to somehow make sure it exists on every possible variant, spreading the implementation around a bunch of different classes. Or use explicit casts. Also I am not aware of any way to use case statements for complex destructuring
<RX14> case variable; when Type; <use type>; when...; end
<RX14> just use when Type and inside the when block variable is typed as Type
<RX14> *unless variable is an instance variable*
<RX14> which you seem to be doing a lot
<FromGitter> <simenge> why should I not be using instance variables
<Papierkorb> Your Lexer class would benefit from using an IO for instance
<RX14> @simenge you can use instance variables
<RX14> you just can't do type restructions on them
<FromGitter> <bew> @simenge (hi!) You can use `case var = @ivar; when Type; <use var>; end`
<RX14> and when your whole program is based around union typed
<RX14> you hit it a lot
<RX14> and yes what @bew said
<FromGitter> <codenoid> lfmaof
<RX14> all you need to do is assign the ivar to a local var so that the compiler KNOWS it isn't going to be changed by another thread
<RX14> would you prefer to get random undebuggable segfaults than a compile error?
<RX14> well, I mean it would turn a race condition into a segfault if we could type restrict on instance vars
<RX14> so we don't
<FromGitter> <simenge> We are still talking about the language that runs in a single OS thread, right?
<FromGitter> <simenge> lmao
<RX14> we're a concurrent language
<RX14> not a parallel language
<FromGitter> <codenoid> yes we are
<Papierkorb> Are you really now complaining how the compiler saves you from arcane bugs in your own code?
<RX14> the condition for race conditions ins concurrency
<RX14> not parallelism
<RX14> it doesn't matter if it runs in a single OS thread if io.write can switch to a different fiber
<FromGitter> <simenge> I cannot imagine how a type restriction can lead to a race condition, just make that op atomic
<RX14> okay
<RX14> if @type.is_a? String; puts @type; end
<RX14> simple code
<RX14> between @type being checked as a string, another thread comes and changes @type
<RX14> and then when you try to puts it it's another type
<RX14> and you get a segfault
<FromGitter> <bew> When you assign `@type` to a local var, any thread/fiber can change `@type` you'll still have your local var on the object you're working with
<FromGitter> <simenge> Well, you can statically determine that a type restriction requires a lock
<oprypin> simenge, what that would really mean is locking whole if-branches
<RX14> creating inisible locks would be a terrible idea
<RX14> it's easy enough to get a deadlock when locks are visible
<oprypin> whenever you have a type restriction, your following code suddenly becomes blocking
<RX14> let alone the performance penalties
<RX14> @simenge please humor us that we've actually thought about how to write this programming language
<FromGitter> <simenge> Thanks for the input guys. You've convinced me that, although I really like Ruby, Ruby as a statically typed language is a terrible idea.
<FromGitter> <simenge> I believe you have thought about things, but you seem to be ignoring a whole lot of good research out there
<Papierkorb> I'm not sure that you actually understand what's going on simenge
<RX14> @simenge ok i'll put it bluntly: none of your .as casts are neccesary (with a few minor tweaks) and if you attempted to learn more about crystal you could remove them all
<FromGitter> <bew> *grabs popcorn*
<Papierkorb> But you showed a clear lack of interest, and chose to ignore our calls on how to do it the right way. Ignorance is a choice, and you can make it. But please don't reflect this onto the Crystal language, its tools nor its community.
<oprypin> agree
<Papierkorb> Especially not on the Community. You can insult a compiler, it won't complain. But Community? NO.
<oprypin> I've been vaguely following the conversation and it's really just you talking your own thing without trying to understand what people are saying
<FromGitter> <simenge> RX14 I will cut this short soon because I'm not about to start a flamewar. But you would not believe the number of obscure error messages that would ONLY disappear once an explicit cast was introduced. I did show an interest in learning, but whenever I mention "this seems to be easier to do with a different approach than the one you chose", you respond aggressively. If I am ignorant and uninterested in learning
<FromGitter> ... about your approach, you are surely exactly the same about every other approach out there
<RX14> @simenge we understand that crystal has a fairly sharp learning curve
<FromGitter> <simenge> Nevertheless, I don't wish to get into a flamewar so I will dip out. You can think of me as a dumb outsider if you wish, I will have my own thoughts on your community's choices as well
<RX14> but I think we've fairly discussed why we havent chosen your suggestions on how to fix this
<RX14> @simenge a shame, I was halfway through removing every cast from your code example
<RX14> i'd love it if you stayed to see how I would write your example
<FromGitter> <simenge> Well, I can't be bothered to stick around being insulted and having a strong urge to insult people back
<RX14> I'm sorry you feel we insulted you
<RX14> we probably have been a bit harsh but you seemed uninterested in following our suggestions
<FromGitter> <simenge> "you showed a clear lack of interest, and chose to ignore our calls on how to do it the right way. Ignorance is a choice, and you can make it." "I've been vaguely following the conversation and it's really just you talking your own thing without trying to understand what people are saying" Etc etc etc.
<jsn-> what about spawn-ed blocks, though? don't they capture the local vars?
<Papierkorb> jsn-: They do capture by referencing them
<FromGitter> <simenge> I came in here making a few comments on how things seem easier to do using other paradigms, and you apparently cannot even comprehend the possibility that this might be true
<FromGitter> <simenge> I'm out.
<Papierkorb> jsn-: If you know C++, it's like doing `[&x]{ x += 1; }` in C++.
<FromGitter> <faustinoaq> Hi @simenge check 👉 https://github.com/kanaka/mal/tree/master/crystal ⏎ ⏎ Is a bit outdated implementation but with a few changes you can get it working 😄
<jsn-> Papierkorb, so, does it mean that the type of local var can also change suddenlY
<jsn-> ?
<Papierkorb> jsn-: Yes indeed
<FromGitter> <codenoid> hi
<Papierkorb> jsn-: In that particular case. The compiler will do the checks for you, so in that moment it's like working with an @ivar
<FromGitter> <codenoid> i got bug when compiling crystal with `--release`
<FromGitter> <faustinoaq> *grabs popcorn* ⏎ ⏎ @bew Never seen a flame-war or something similar here before 😆
<FromGitter> <codenoid> oh, fixed with `--no-debug`
<Papierkorb> codenoid, that's a known issue with an old LLVM version. Are you using Crystal through Docker or wihtout?
<FromGitter> <codenoid> without a docer
<FromGitter> <codenoid> ducker
<FromGitter> <codenoid> docker
<jsn-> Papierkorb, sorry, can you elaborate? if a.is_a? String; spawn { a = 1 } ; <blocking op>; puts a.size ; end -- will this be a compile error?
<Papierkorb> jsn-: Yes it will be
<jsn-> huh!
<jsn-> nice.
<jsn-> but umm, why can't it be the same for ivars, then?
<FromGitter> <bew> @faustinoaq yeah...
<FromGitter> <bew> I actually felt bad for him reading your answers, but didn't know how to tell you to calm down..
<FromGitter> <bew> I think I can understand why he's gone now :/
<FromGitter> <imonmyown> seems like the first stress test of a growing language
<FromGitter> <faustinoaq> @bew Oh, there is when emojis do a good job, after a "possible emotional/insult" language, you just put a smile emoji ( 😄 ) and is done! no problems 😉
<Papierkorb> bew, how long you've been in dev chat channels?
<FromGitter> <bew> Was wondering, how is represented `nil` in memory?
<FromGitter> <bew> Not long, crystal is actually my 1st
<jsn-> Papierkorb, but isn't the type of local var also ambiguous inside of "if ...is_a?()" after any blocking op (at least in presence of other fibers changing it's type)?
<jsn-> ("its", duh)
<oprypin> jsn-, that blocking op can't change the local var
<FromGitter> <faustinoaq> > Why `sleep` needed here? Thanks you. ⏎ ⏎ @MrSorcus you need to keep main Fiber running, spawned Fibers depend on it. ⏎ ⏎ You can try this too: ... [https://gitter.im/crystal-lang/crystal?at=5a3558e7ba39a53f1a6b4833]
<jsn-> oprypin, a block spawn-ed before can wake up during a blocking op, and it can change the type
<Papierkorb> bew, While harshness exists, it's mostly the result of yearlong experience of specific behavioural patterns the other side exhibits. However, if you do feel that something is going wrong (Anything, really), just chime in. You can even "take over" a help session by simply writing your own explanation directed towards the person being helped. Commonly, the helpee will stop listening/reading what the other parties write and listen to you
<Papierkorb> instead.
<oprypin> jsn-, local vars are local in more ways than one. a block spawned has no access to local variables, only perhaps to the objects that they are pointing to
<FromGitter> <bew> Papierkorb ty, I've thought about this, but I'm on the phone right now, so can't do much
<jsn-> now I'm more confused. I thought, from Papierkorb's comment, that a spawn-ed block can capture a local var and change its type
<oprypin> jsn-, it captures the object that the var was pointing to
<oprypin> if a block changes an object's member, yeah, that can be a problem in the general sense and the reason why you still need locking primitives without parallelism
<jsn-> ah! but not the slot?
<Papierkorb> bew, also from experience, once someone doesn't read your statements anymore, they're beyond help for this session. They should try another round an hour or day later - No kidding. Same for helpers once they get burned. Am Human, yo.
<oprypin> but a block cannot change what that local variable was pointing to and hence cannot change its type
<jsn-> oprypin, https://gist.github.com/Papierkorb/946cee0118602e3146aa2438aede96f0 -- this seems to demonstrate that you're wrong
<RX14> it's pretty easy to write this lisp interpreter without .as
<RX14> lol
<oprypin> jsn-, .class is the type of the value, not the type of the variable
<RX14> its actually a pretty nice lisp interpreter
<oprypin> jsn-, consider this https://carc.in/#/r/392v
<oprypin> jsn-, but seems like I am still wrong because this did actually change what that variable was pointing to
<jsn-> yep
<Papierkorb> jsn-, type inference looks at all places a variable is assigned to and checks its type after doing so. This is like "If we end up here, even if unlikely, what happens to the variable?". You can try removing the #send on line 11 in my arcane_lvar.cr sample, it will still tell you that `var` is a `String | Int32`
<Papierkorb> jsn-, Type inference is also the source of confusion people face when trying to use OptionParser, where they assign `foo = nil` above the parse! block, and in there do something like `on(..){ |v| foo = value }`. There have been misunderstandings a bunch of times in here already why `foo` is still nil-able afterwards.
<jsn-> https://carc.in/#/r/392w prings Int32 | String, but https://carc.in/#/r/392x prints String
<jsn-> it makes sense to me
<jsn-> but why can't the same be done with ivars?
<FromGitter> <bew> Papierkorb I think I see your point, but I was also thinking that when the kind of discussion we had happens, when the person doesn't want to follow your tips, it would be better to show him an actual code snippet and start discussing about why doing it this way, without going in flamewar like this (bit no idea how applicable this is really..)
<Papierkorb> Because the object containing the @ivar could be referenced from a different fiber (Or Thread), and change the @ivar. Thus the compiler assumes that the "whole world", and not just what it sees right now, has writing access to it.
<jsn-> something about ivars visibility being harder to track?
<jsn-> Papierkorb, aha, yep, something like that
<Papierkorb> Simply said, yes
<jsn-> ok, thanks, now it's a bit more clear to me
<jsn-> ah, "the whole world" as opposed to "just this file", at maximum, right? because local var scope can't exceed one source file
<Papierkorb> As opposed to "just this scope"
<oprypin> local var scope definitely can't exceed one source file but it's much narrower than source file
<jsn-> yeah, you can't even capture them in def-s, iirc (which is sometimes annoying)
aroaminggeek[awa is now known as aroaminggeek
aroaminggeek is now known as aroaminggeek[awa
<Papierkorb> You can't, correct. Use @ivar oder @@cvars instead ("Wrap your script into a class"). If you need a local, small helper function, you can use procs as in lambdas
<Papierkorb> Something like `hexify = ->(x){ x.to_s(16).rjust(4, '0') }`
<jsn-> yeah, i had to use procs in my icfp2006 vm because of that, class var access is much slower, apparently
<Papierkorb> Shouldn't be much slower than ivars, but slower than local vars
<RX14> ok I did it
<Papierkorb> Mh dunno what LLVM does, but cvars could be faster than ivars - Except that the cvar may not yet reside in memory cached
<Papierkorb> -d
<RX14> I keep thinking that `when String, Int64` works
<RX14> but it doesn't
<Papierkorb> Why not?
<RX14> wait what
<RX14> damnit im confused let me rethink this
<RX14> nope i'm wrong I don't understand what I broke but it works now
<RX14> but ignore me i just got myself in a muddle
<RX14> do you get github notifications for comments in gists?
<RX14> you can see the diff in the revisions tab
<Papierkorb> RX14: Dunno about notis, maybe if you @ someone
<RX14> i did both
<RX14> just in case
<RX14> probably could @ him here
<Papierkorb> heh that's interesting. My 6502 interpreting emulator gets more a bigger speed gain out of caching instructions than my big computer (big 2x, notebook 3x). Yet, when dynarec'ing, my big computer gets it to about 1.3GHz, and the notebook to 1.2GHz.
<Papierkorb> Wondering if that's benching my RAM
<FromGitter> <faustinoaq> > c++ expres.js like framework ⏎ > https://github.com/ipkn/crow/wiki/Installation ⏎ ⏎ @unreadable I thought it was https://github.com/geppetto-apps/crow 😆 [https://gitter.im/crystal-lang/crystal?at=5a3569c9ba39a53f1a6b9359]
astronavt has joined #crystal-lang
astronavt has joined #crystal-lang
astronavt has quit [Remote host closed the connection]
aroaminggeek[awa is now known as aroaminggeek
aroaminggeek is now known as aroaminggeek[awa
aroaminggeek[awa is now known as aroaminggeek
aroaminggeek is now known as aroaminggeek[awa
aroaminggeek[awa is now known as aroaminggeek
aroaminggeek is now known as aroaminggeek[awa
<jsn-> (also, there's Time#epoch_f and Time.epoch, but no Time.epoch_f, oh come on)
<Papierkorb> I'd be fore removing Time.epoch, Time.now.epoch isn't much longer and more clear in behaviour
<Papierkorb> And Time is a struct, its construction is basically free
<jsn-> Time.epoch is nothing like Time.now.epoch, though
<Papierkorb> Oh now I see
<Papierkorb> why isn't that called from_epoch
<jsn-> yep
<Papierkorb> That name change would be great, and I don't see a reason for not having a Float overload too.
<Papierkorb> Mh I wonder if having a `Time.unix_epoch` wouldn't be neat so you could do `Time.unix_epoch + offset.seconds`
<Papierkorb> Or rather, would have to do, instead of having special methods
<jsn-> in ruby it's called Time.at
alex`` has quit [Quit: WeeChat 1.9.1]
Sauer2 has joined #crystal-lang
<Sauer2> @oprypin, @sija: Hi. Remember when I asked you about injecting foreign functions into an interpreter not too long ago? The good/hairy news is it can be done using .id instead of Class types.
<Sauer2> The bad news is I suspect you really have to rely on macro expansion order.
<Sauer2> But all in all it works rather well. Kudos to whoever designed the macro system.
<Sauer2> BTW: What was the most impressing thing you have seen implemented in the macro system so far?
<Papierkorb> Impressive in which regard?
<Papierkorb> I mean you can literally implement a new language with it
<Papierkorb> Sauer2: Only done (in plain macro code) hash calculation, transparent RPC class generation, a few mapping-patterns - So nothing too insane. Someone, dunno if they pulled through, wanted to use macros to add aspect oriented programming paradigms to Crystal. Groogy developed a contract-driven development shard (called `crystal-clear` iirc)
<Papierkorb> You can technically use macros to generate SQL statements out of Crystal expressions, but no idea if someone created that's more than a small test of this
<Sauer2> @Papierkorb: That's pretty cool.
Sauer2 has quit [Quit: Page closed]
<FromGitter> <bew> Ziprandom did some good things with macros iirc for its graphql shard
aroaminggeek[awa is now known as aroaminggeek
aroaminggeek is now known as aroaminggeek[awa
claudiuinberlin has quit [Quit: Textual IRC Client: www.textualapp.com]
aroaminggeek[awa is now known as aroaminggeek
aroaminggeek is now known as aroaminggeek[awa
aroaminggeek[awa is now known as aroaminggeek
aroaminggeek is now known as aroaminggeek[awa