<FromGitter>
<faustinoaq> > It doesn't even find def's in the same file ⏎ ⏎ Papierkorb, seems that something is going wrong here, let me check, I disabled it by default because I had some issues in past
<Papierkorb>
Yeah I know of that setting, but it's not that useful when you have multiple projects
<Papierkorb>
or can I say "src/*.cr" in there?
<FromGitter>
<faustinoaq> Yeah, I tried that, Basically I pass mainFile as second argument for `crystal tool implementation -c /full/path/foo.bar:line:col /full/path/mainfile`, this problem ith `src/*.cr` as main file is that crystal doesn't work as I expected, I tested before and didn't work
snsei has joined #crystal-lang
ephemera_ has quit [Ping timeout: 240 seconds]
ephemera_ has joined #crystal-lang
<Papierkorb>
faustinoaq, write a tempfile which simply requires those files, then load that as main file into crystal
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
<FromGitter>
<georgeu2000> I have the following params: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ How can I handle nil params with an instance variable? How can I handle a different params (say `OtherParams` in a `@params` variable? [https://gitter.im/crystal-lang/crystal?at=59d842d1bbbf9f1a38306a13]
mooe_ has joined #crystal-lang
<mooe_>
is there any way to get a list of instance variables like Foo.new.instance_variables in ruby?
<mooe_>
nevermind, its possible using macros and @type.instance_vars
_whitelogger has joined #crystal-lang
snsei has quit [Remote host closed the connection]
gokmen has quit [Quit: bye.]
RickHull has quit [Ping timeout: 260 seconds]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
claudiuinberlin has joined #crystal-lang
mooe_ has quit [Quit: Connection closed for inactivity]
<FromGitter>
<Brusalk> Hey All, been following Crystal for a long time, and starting to use it for personal projects. It's been awesome.
<FromGitter>
<Brusalk> I have run into something I'm curious about,
<FromGitter>
<Brusalk> Is it not possible to accept a block/proc with a method that can have multiple signatures? For example: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Am I misunderstanding union types and/or is there a better way to do this sort of thing? [https://gitter.im/crystal-lang/crystal?at=59d86e7bb20c642429d20ae6]
_whitelogger has joined #crystal-lang
DTZUZO has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
DTZUZO has quit [Ping timeout: 240 seconds]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
<crystal-gh>
[crystal] firejox opened pull request #5086: Make Tuple#map_with_index return a Tuple. (master...tuple_unified_map_behavior) https://git.io/vdu2Q
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 255 seconds]
DTZUZO has joined #crystal-lang
rohitpaulk has joined #crystal-lang
danielpclark has joined #crystal-lang
<FromGitter>
<iambudi> How to capture error code from exception? Using ex.message only gives the error message string.
<FromGitter>
<bew> @Brusalk indeed it doesn't work, and it doesn't seems to be possible... (@monouser7dig try to instanciate a formatter, you'll see the error)
<FromGitter>
<bew> @iambudi which exception? all exception don't have an error code
<Groogy>
as long as the structures names and methods describe well what they are doing I think its gonna improve the code base
<FromGitter>
<iambudi> > @iambudi which exception? all exceptions don't have an error code ⏎ I want to capture database exception error.
<FromGitter>
<bew> and which exception is it?
<FromGitter>
<iambudi> For example, using mysql driver to connect to db and do a record insert. When primary key duplicate it will throw error and we can capture the message : Duplicate entry ‘1’ for key ‘PRIMARY’. What i would like to capture is the error code of mysql : 1062. Is this related to db drive or by general crystal does not throw error code?
mrCrystal has joined #crystal-lang
<mrCrystal>
hello how can I run 2 loops at the same time? can i create threads?
<FromGitter>
<bew> ahah sorry, I have desktop notifications & I was already on my browser (with fast vim keybindings), might help to do things faster ;)
<RX14>
i tried vim keybindings on my browser but never really made use of tem
<FromGitter>
<bew> in this case I only used `y` to copy the url, combined with firefox's omnibox, I had to write `conc` to access the docs about concurrency
<FromGitter>
<bew> and `alt-1` to goto first tab (I always pin gitter in first tab=
<RX14>
well i only access that page for linking to other people so...
<RX14>
its not in my omnibox
<FromGitter>
<bew> I also almost only access this one for linking, maybe I accessed it more often (or more recently)
<FromGitter>
<bew> yesterday I learned about frecency (frequency + recency), used by omnibox-like tools
<FromGitter>
<bew> @iambudi which mysql shard are you using?
ShalokShalom_ has joined #crystal-lang
<hightower4>
Howdy fellows
<mrCrystal>
where are all the math things in crystal? sin cos atan atan2 sqrt?
<Papierkorb>
In the `Math` module partially, "missing" stuff is directly defined on the `Number` types
<mrCrystal>
ah okay!
<mrCrystal>
"myint-1.times do" does not work. What can I do?
<mrCrystal>
do i really need to define a new variable for this
<Papierkorb>
`(foo - 1).times`, or with ranges: `0...foo.each`
<mrCrystal>
ooh thanks
<FromGitter>
<bararchy> So, stuck on a logical problem. ⏎ I got an `Array(String)` of URLs with parameters (id=1&bar=2&foo=3,etc..) ⏎ for each url I change one parameter, and keep all others, which means I end up with `URLs * params(for each)` kinda calculation which is fine, now to my issue. ⏎ I want to continuesly do this and add stuff to the parameters, but going with the same logic I just add more and more urls instead of
<oprypin>
i was trying to find any way at all to print the generated code from the macro, and the extremely funny thing is that just adding `p` did that. because it's a compilation error.
<FromGitter>
<georgeu2000> Cool.
<FromGitter>
<georgeu2000> It seems like since Crystal is typed JSON works like a hash with arbitrary types...
<oprypin>
georgeu2000, yeah that's why people dont like it
<oprypin>
json mapping abstracts that away. when it's applicable, anyway
<Papierkorb>
You can pull the class into the class of course. apart from that, no.
<oprypin>
georgeu2000, these are already combined and have nested json. what's the problem?
<FromGitter>
<georgeu2000> I was wondering if you have to declare the Location as a separate class. I see we do.
<Papierkorb>
You can use a `delegate` to the inner values if you insist. But for the general case, I don't see much point for this
<Groogy>
been trying to figure out why some triangles behind others were being painted over the other
<Papierkorb>
writing foo.bar.baz instead of foo.bar_baz or foo.baz isn't much worse, but is so much more structured. Also somewhat prevents god objects.
<oprypin>
as Papierkorb suggested, you can move the line `class House` to the very beginning while keeping the reset the same
<Groogy>
then I realized that in my shader script I forgot to switch function = Always to function = Less for the depth values
<FromGitter>
<georgeu2000> OK thanks.
<FromGitter>
<georgeu2000> Are there any examples of writing an API with Crystal?
<Groogy>
mine? ^^
<Papierkorb>
Groogy: C features got another jump in stability. Missing: 1) Function callbacks 2) vararg arguments 3) complex #define's (Like `1 | 2`). Of those, 3) is by far the most complex to solve.
<Groogy>
hmm you feel it got far enough where I should give it a try on opengl?
<oprypin>
Papierkorb, it's actually impossible to solve
<Papierkorb>
On the upside, for pure C APIs, if you don't use any C++-side conversions, you can now leave out the C++ generator completely, which gets it in line with pure binding generators
<oprypin>
complex defines include arbitrary pieces of C code, not even necessarily valid on their own
<Papierkorb>
Groogy: Except for the listed points, it seems to work. The tests are promising too.
<Papierkorb>
oprypin: Of course
<Papierkorb>
Groogy: The biggest obstacle is #define mockery prevalent in many C libs. If those are not used (or wrapped through in a `enum`), then you should be fine.
<Papierkorb>
Mh for complex-but-self-contained and constant object-like macros I might have an idea for a reasonably easy solution.
<oprypin>
that's nice :)
<Groogy>
you mean like the freetype weird macros they did? D:
<Papierkorb>
Yeah those fall into that just mentioned category
<Groogy>
crap
<Groogy>
but I'll do a test on GL tomorrow
<oprypin>
no i think "fall into that just mentioned category" is a good thing, right?
<Papierkorb>
Ah how boring, that idea might just work. I had a much more fun solution in my mind.
<Papierkorb>
May do that anyway when I have a few days for the lulz
<FromGitter>
<monouser7dig> looking at array, is there some plan for rotate with boundaries and or partial sort?
<Papierkorb>
Views would be nice to have
<Papierkorb>
Though ArraySlice may be a more crystaly name
<FromGitter>
<monouser7dig> for rotate you mean? thought about slice as well
<FromGitter>
<bew> But would it ba safe?
<FromGitter>
<bew> be*
<Papierkorb>
With Slice? I have to say "no" but ....
<FromGitter>
<monouser7dig> and why is there a replace function? what is the difference to just assign it to a different array?
<Papierkorb>
What I mean would be a class that'd operate on a specific range of an Array
<FromGitter>
<monouser7dig> (I mean if it had a range, but it does not)
<Papierkorb>
Which would be perfectly safe
<FromGitter>
<monouser7dig> for partial sort that aint work though
thews has joined #crystal-lang
thews has quit [Changing host]
thews has joined #crystal-lang
<FromGitter>
<monouser7dig> or a nth_element
<oprypin>
monouser7dig, this is not c++. you'd make a copy of the array and do something with it lol
<oprypin>
arrays flying left and right here
<oprypin>
that said, making a view class is very easy
<FromGitter>
<monouser7dig> if you want something else than just web maybe do some algorithms once, properly 😄
<oprypin>
no it's fine
<FromGitter>
<monouser7dig> hm ⏎ yet sth easy like Levenshtein is included 😄
<oprypin>
what a disaster, `rotate!` and `sort!` are defined directly on Array
<FromGitter>
<monouser7dig> how is this a disaster
<oprypin>
they cant be reused for other data types
<FromGitter>
<monouser7dig> b = a.clone in this case would be clear instead of a strange replace?
<FromGitter>
<sdogruyol> lol
<FromGitter>
<sdogruyol> nice one @Papierkorb
<oprypin>
monouser7dig, that implies destruction of former value of b
<oprypin>
which is a mmory reallocation
<oprypin>
and there are special cases like `class A; getter a : Array; end` you can't reassign that value but can .replace
<FromGitter>
<faustinoaq> > write a tempfile which simply requires those files, then load that as main file into crystal ⏎ ⏎ Papierkorb, Good Idea 👍
<FromGitter>
<monouser7dig> if I have b.replace(a) instead of b = a.clone #all b values are gone in both cases, how can one require more effort than the other? ⏎ ⏎ so you tell me if I only have getter access I can still replace, does not sound doof IMO
<FromGitter>
<monouser7dig> sound good*
<FromGitter>
<eliasjpr> The new AmberFramework website is now live. The team has recently upgraded the website looks and documentation. It looks beautiful! Take a look https://www.amberframework.org/
<oprypin>
please don't tamper with scrolling, thx
<FromGitter>
<faustinoaq> Great work @eliasjpr 👏 👏
<oprypin>
that website just triggers me
<Papierkorb>
eliasjpr, good job
<FromGitter>
<imonmyown> looks damn hot
<FromGitter>
<eliasjpr> Thanks guys. 😄 the docs still needs some work which we are currently working on :)
<FromGitter>
<bararchy> On mobile the getting started button is a little chopped
<FromGitter>
<imonmyown> Oh, there's even heroku support... amazing
<FromGitter>
<imonmyown> So, heroku is like running native code?
<FromGitter>
<eliasjpr> No, there is a heroku buildpack, amberframework.org is currently running on heroku
<FromGitter>
<imonmyown> So how does it work, is it transpiled to ruby or? ... I don't get it
<FromGitter>
<faustinoaq> > is it transpiled to ruby or? ⏎ ⏎ What do you mean ? @imonmyown
<Papierkorb>
Heroku is simply a managed hoster. They got big with rails hosting, but they don't "run" on ruby
<FromGitter>
<imonmyown> So it's a native binary eventually or...?
<Papierkorb>
they just run your program, whatever it is. You're basically paying to run a Docker-like container.
<FromGitter>
<imonmyown> Ok, got it now
<FromGitter>
<eliasjpr> the site gets compiled on the build process and then the process gets spin up
<FromGitter>
<eliasjpr> by one of the dynos
<FromGitter>
<imonmyown> I used to think they only supported rails
<FromGitter>
<monouser7dig> oprypin actually this memory reallocation thing, could you elaborate how an assignment is less efficient?
<FromGitter>
<imonmyown> @faustinoaq it's a joiner of "transcribe+compile", some crazy idea crossed my mined that they used this trick to make crystal work like ruby
<oprypin>
a.replace(b) -- a has memory allocated for its items. the same memory location gets overwritten with b's items. a = b.clone -- a new memory region gets allocated, b's items written to it, a gets destroyed
<oprypin>
i should say `dup` not `clone`
<FromGitter>
<faustinoaq> @imonmyown haha, no problem 😄
<FromGitter>
<monouser7dig> well replace is like dup or like clone? the doc does not tell me 😟 but the allocation actually makes sense as long as b is smaller than a, otherwise it's probably not a real deal? ⏎ ⏎ still I find this replace command really weird especially after you told me about the getter thing (which makes kind of sense since it is an instance method but still)
<FromGitter>
<monouser7dig> another cool option would be to have array#permute visiting everything once https://danluu.com/sattolo/, it's easy but a really nice thing to have
<FromGitter>
<monouser7dig> I see that is shuffle nvm
<oprypin>
monouser7dig, `replace` is indeed weird. you shouldn't really think much of it in regards to getter, because there are a ton more ways to achieve the same effect through a getter anyway. that's how passing objects by reference works
<FromGitter>
<monouser7dig> If I'd want to make sure I'd monkey patch it
<oprypin>
what
<FromGitter>
<monouser7dig> open Array and overwrite replace
<Papierkorb>
just why
<FromGitter>
<monouser7dig> why would you have it? just mmcopy?
<Papierkorb>
you realize that there's a ton of other possibilities to overwrite the array data, right?
<FromGitter>
<monouser7dig> sane ways?
<Papierkorb>
#[]= ?
<FromGitter>
<monouser7dig> if it only has a getter?
<Papierkorb>
Dude. Pass by Reference.
<FromGitter>
<monouser7dig> what is the deal in respect to access privilege?
<Papierkorb>
... Really, just try it.
<FromGitter>
<monouser7dig> sure does not work if I pass an object and try to access an instance that has a getter only
<FromGitter>
<monouser7dig> try to set *
<FromGitter>
<monouser7dig> is it sensible opening an issue for redefining sort and rotate and maybe others on the classes they actually depend on (comparable etc.)? (https://gitter.im/crystal-lang/crystal?at=59d92d12e44c43700a062f26) ⏎ Why should the implementation make such restrictions? ⏎ or was there some consideration that led to the decision that is was best to implement them straight into array? ⏎ Or is it just
<oprypin>
monouser7dig, the ability to sort depends on the type of container, that's what you should be talking about
<FromGitter>
<monouser7dig> that is what I mean saying indexable
<oprypin>
comparable is just a tiny detail that is not even specified anywhere. sort just uses `<` method and if it's not there it can't compile
<oprypin>
so you said "is it sensible opening an issue for redefining sort and rotate and maybe others on the classes they actually depend on (comparable etc.)?"
<oprypin>
is it a very unfortunate typo?
<oprypin>
it is true that `sort!` and `rotate!` can be implemented on Indexable and that needs to be brought up
<oprypin>
Comparable, as I was saying, is an unrelated tiny detail
<FromGitter>
<monouser7dig> comparable etc was not meant as if they all depend on comparable but was meant in a way that they should only depend on the "interfaces (java)" they depend on
<FromGitter>
<monouser7dig> I should say module, not interface here probably 😄
<oprypin>
Also note that these cannot be implemented on `Iterable` or `Enumerable` (c++ equivalent forward iterator)
<FromGitter>
<monouser7dig> > **<oprypin>** it is true that `sort!` and `rotate!` can be implemented on Indexable and that needs to be brought up
<oprypin>
monouser7dig, sorting depends on `<` method. Comparable is just a convenience thing defining `<`, `<=` and others
<FromGitter>
<monouser7dig> > > **<oprypin>** it is true that `sort!` and `rotate!` can be implemented on Indexable and that needs to be brought up ⏎ ⏎ that's it, thanks
<FromGitter>
<monouser7dig> does sorting really depend on < like if you have a partial ordering (https://crystal-lang.org/api/0.23.1/PartialComparable.html) you might not even need this every time? you do not have to enforce a strict < relation between every two elements just to establish a valid sort I mean
<oprypin>
monouser7dig, it does not depend on any module or any relation. literally `<` method.
<oprypin>
actually im not exactly sure what method it depends on but it doesnt matter
<FromGitter>
<monouser7dig> yeah that is not the point afterall so I'll leave this with you and at the time you think it is appropriate this might pop up in your mind and the issue tracker?
<oprypin>
i have no idea what PartialComparable is doing in stdlib, literally 0 uses of it
<oprypin>
georgeu2000, yeah you need to register the namespace. maybe as part of the xml document, even. if not, i think bew linked a way to register it above