Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 13:47
    straight-shoota closed #12051
  • 13:47
    straight-shoota closed #12050
  • 12:17
    beta-ziliani edited #7318
  • May 15 08:43
    r00ster91 closed #7318
  • May 15 08:17
    r00ster91 closed #7690
  • May 14 17:01
    Blacksmoke16 labeled #11995
  • May 14 13:03
    webhive closed #12055
  • May 14 10:19
    straight-shoota milestoned #12051
  • May 14 10:00
    I3oris edited #12051
  • May 14 08:45
    oprypin review_requested #11977
  • May 13 23:29
    Blacksmoke16 unlabeled #12061
  • May 13 22:56
    Blacksmoke16 edited #12061
  • May 13 22:56
    Blacksmoke16 edited #12061
  • May 13 22:54
    Blacksmoke16 labeled #12061
  • May 13 22:54
    Blacksmoke16 labeled #12061
  • May 13 22:54
    Blacksmoke16 labeled #12061
  • May 13 22:54
    Blacksmoke16 opened #12061
  • May 13 20:14
    straight-shoota labeled #12060
  • May 13 20:14
    straight-shoota labeled #12060
  • May 13 20:14
    straight-shoota opened #12060
Bar Hofesh
@bararchy
or is it only for types ?
From IRC (bridge bot)
@FromIRC
<Groogy> Morning!
<Papierkorb_> Morning
<Papierkorb_> @bararchy, only type aliases. Method aliases are frowned upon. If you meant a delegator, you can use the delegate macro delegate foo, bar, baz, to: @something
Bar Hofesh
@bararchy

I just want to have two names for the same method , let's say I have .destory, and I want it to respond to .close too, and doing

def close
  destory
end

is a little ugly

From IRC (bridge bot)
@FromIRC
<Groogy> huh what does the delegate macro do exactly? Not seen that before
<Groogy> also @bararchy a good question would be why do you want two symbols to correspond to the same functionality?
Bar Hofesh
@bararchy
so that I can conform with the original lib, and also the languge standards
:)
From IRC (bridge bot)
@FromIRC
<Groogy> #destroy is sometihng I usually associate with resources while #close would be something like IO or a window
<Groogy> ah
<Yxhuvud> groogy: it forwards a method call to whatever it delegates to
<Groogy> so it would forward foo.bar to @something.bar?
<Papierkorb_> yes
<Papierkorb_> @bararchy, it looks ugly because aliases are ugly
<Papierkorb_> Ruby has been burnt by it, its stdlib is full of aliases. It sucks.
<Yxhuvud> I kinda like it. YMMV.
Bar Hofesh
@bararchy
is there a way I can know if an object is being called from the main Fiber or from another spawn ?
Bar Hofesh
@bararchy
So, started working on TensorFlow bindings for Crystal, if anyone want's to join in: https://github.com/NeuraLegion/tensorflow.cr, it's MIT licensed ofc
imonmyown
@imonmyown
@bararchy not sure I can be of help, but if I can let me know how
sorry, didn't get to Contributing section
Bar Hofesh
@bararchy
:) @imonmyown you can see what is under development, just pick something you want to add, see the referances, and PR
imonmyown
@imonmyown
Ok, got it :)
imonmyown
@imonmyown

I don't seem to be able to assign to an element of a newly allocated array

    prefix = Array(Int32).new(arr.size.as Int)
    prefix[0] = 1

Getting Index out of bounds...

From IRC (bridge bot)
@FromIRC
<Papierkorb_> As expected. That array is empty. Though your snippet looks like you can #map from it. Otherwise, you can set the initial value to pre-fill the array to the given size.
From IRC (bridge bot)
@FromIRC
<jokke> i was just playing around with crystal to expose c functions to create dynamic libraries
<jokke> for c
<jokke> but i ran into my first problem: crystal redefines main
<jokke> can i circumvent this?
<jokke> Papierkorb_: your into this low level stuff, any ideas? :⁠)
From IRC (bridge bot)
@FromIRC
<Papierkorb_> jokke: It has since been broken, the empty prelude began to ship with a fun main recently. There's also now way (afaik) to remove a fun after defining it somewhere. You can get around this by carefully writing a custom prelude which doesn't require anything defining the main()
<Papierkorb_> jokke: Got it.
From IRC (bridge bot)
@FromIRC
<Papierkorb_> Hang on..
From IRC (bridge bot)
@FromIRC
<Papierkorb_> Have a look at the real main implementation however, as you'll want to start the garbage collector etc.
Ary Borenszweig
@asterite
We can probably have a flag to not generate main, for example NO_MAIN. But dynamic libraries are very limited right now. For example is_a? won't work well.
From IRC (bridge bot)
@FromIRC
<Papierkorb_> @asterite, I think that would be a useful thing to have. Not for the many, but for the some :⁠)
<Papierkorb_> No idea about embedded systems, but I can imagine those needing some early configuration before the C code would jump into Crystal-land (and thus, its main)
Ghost
@ghost~55586c4815522ed4b3e08557
Nice gist Papierkorb!
What do you mean by removing a fun after its definition? How?
From IRC (bridge bot)
@FromIRC
<Papierkorb_> @bew, there's noundef_fun functionality in the language (or the like), which would let you to get rid of the main().
<Papierkorb_> Not that I want that feature, a --no-main or --flag NO_MAIN would be ideal
<jokke> yeah that'd be great
<jokke> and also easy to implement
<Papierkorb_> custom flags would be kinda neat though cough
<jokke> well you could just use NO_MAIN=1 ...
Ghost
@ghost~55586c4815522ed4b3e08557
Oh okay I understood there was a way (you said "there's now way" instead of "no way"! )
From IRC (bridge bot)
@FromIRC
<jokke> and then {% if env("NO_MAIN") %}
<jokke> or something similar