Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 30 23:49
    Tamnac synchronize #13026
  • Jan 30 23:43
    Tamnac synchronize #13026
  • Jan 30 22:36
    straight-shoota milestoned #13011
  • Jan 30 22:36
    straight-shoota milestoned #13011
  • Jan 30 22:30
    oprypin edited #13026
  • Jan 30 22:03
    HertzDevil labeled #13031
  • Jan 30 22:03
    HertzDevil labeled #13031
  • Jan 30 22:03
    HertzDevil opened #13031
  • Jan 30 20:20
    straight-shoota closed #13027
  • Jan 30 20:19
    straight-shoota closed #13028
  • Jan 30 20:19
    straight-shoota closed #13025
  • Jan 30 20:19
    straight-shoota closed #13023
  • Jan 30 20:19
    straight-shoota edited #13025
  • Jan 30 20:06
    straight-shoota assigned #13030
  • Jan 30 20:06
    straight-shoota opened #13030
  • Jan 30 20:06
    straight-shoota labeled #13030
  • Jan 30 20:06
    straight-shoota labeled #13030
  • Jan 30 15:56
    straight-shoota labeled #13026
  • Jan 30 15:53
    straight-shoota converted_to_draft #13024
  • Jan 30 15:23
    Blacksmoke16 labeled #13029
George Dietrich
@Blacksmoke16
That example is on the top level
Oh
I think that'll be possible in the next version, until then it's probably still a good practice to namespace your stuff
From IRC (bridge bot)
@FromIRC
<Guest64> true
<Guest64> https://www.bookstack.cn/read/crystal-lang/syntax_and_semantics-macros.md i found this and things are starting to click together now. thanks again
Kirk Haines
@wyhaines
@guest64 -- I can give you a little example of the kinds of thing that I am talking about in a bit.
Kirk Haines
@wyhaines

@guest64 --

module MyProcs
   Proc1 = ->(arg0 : Int32, arg1 : Int32) { arg0 + arg1 }
end

module MyProcs
  Proc2 = ->(arg0 : String, arg1 : String) { arg0.to_i64 + arg1.to_i64 }
end

macro build_a_hash
  {%
    foo = {} of Nil => Nil
    MyProcs.constants.each do |const|
      foo[const.stringify] = "MyProcs::#{const.id}".id
    end
  %}

MyHash = {{ foo.stringify.id }}
end

build_a_hash

pp MyHash
pp typeof(MyHash)

You are still going to have problems with types, though, if you have a single hash that holds everything.

Try it and you will see what I mean.

George Dietrich
@Blacksmoke16
can you build a binary from input via stdin or something?
i.e. w/o needing a file
didactic-drunk
@didactic-drunk
This is an idea I'm playing with. Is it possible to translate "#{class}.{method}" to a fixed offset at compile time? Example:
@[Measure]
def foo
end

macro finished
  {% for meth in ... %}
    def {{meth...}}
      slot = {{ slot_for @type, meth.name }}
      Fiber.current.measurements[slot].measure do
        previous_def
      end
    end
  {% end %}
end
George Dietrich
@Blacksmoke16
so that the methods are created in a specific order?
Quinton Miller
@HertzDevil
however this index is the overload order not the declaration order
it's still unique though
Kirk Haines
@wyhaines

@Blacksmoke16

{{ system("cat") }}

STDIN is defined for macro code, but off the top of my head right now I don't know if there is a way to read from it with macro code currently.

j8r
@jrei:matrix.org
[m]
{{ read_file }}
I didn't read before on what you want to do, here is only a better snippet
didactic-drunk
@didactic-drunk
Is it possible to monkey patch IO::FileDescriptor#read? https://carc.in/#/r/bj7v
oprypin
@oprypin:matrix.org
[m]
why tho
didactic-drunk
@didactic-drunk
Measure wait time
From IRC (bridge bot)
@FromIRC
<xyhuvud> it should work to monkeypatch as long as you make certain the original is already loaded. file_descriptor should be loaded though
<xyhuvud> it works for me, but then I don't depend on previous_def.
didactic-drunk
@didactic-drunk
previous_def is the important part. require "socket" doesn't seem to help. Is this a load order problem or issue with modules? https://carc.in/#/r/bj8y
George Dietrich
@Blacksmoke16
IO doesn't implement unbuffered_read
FileDescriptor should because it includes the module, so it should deff have that method
wonder if it's because the method is coming from another module
in this case you'd prob want to use super
From IRC (bridge bot)
@FromIRC
<xyhuvud> FileDescriptor implements it by itself though
George Dietrich
@Blacksmoke16
it's implemented via the include Crystal::System::FileDescriptor
so ends up not being a redefinition
From IRC (bridge bot)
@FromIRC
<mikko> well this is a fun bug crystal-lang/crystal#2485
<mikko> my almost trivial code has been compiling for many minutes due to this line: StaticArray(Bool, 10_000).new(true)
George Dietrich
@Blacksmoke16
nice
is there a reason to have a 10k member static array tho?
From IRC (bridge bot)
@FromIRC
<mikko> i was just wanting to experiment with bitarray vs staticarray vs array
<mikko> trying to see what kind of performance i get with each
George Dietrich
@Blacksmoke16
fair enough
Kirk Haines
@wyhaines
I think that if you search the archives in here, you will find some other discussion of StaticArray and that compilation performance cost. I remember seeing it....a yearish-ish ago.
didactic-drunk
@didactic-drunk
@Blacksmoke16 super doesn't work. https://carc.in/#/r/bj9h
George Dietrich
@Blacksmoke16
welp
Quinton Miller
@HertzDevil
Lewis E. Bogan
@lebogan

@Blacksmoke16 and all who responded to my raspberry pi madness: I finally got 1.0 to compile on a model 4b with 4gb ram. Why? Why not. After setting al the environment stuff, it works like a charm. I did have to compile llvm-10 for the rpi which was 'painfull' - almost 10 hours! I kept notes if anyone is interested - I consolidated a lot of stuff from online plus community help. A big thanks to everyone

Crystal 1.0.0 ()

LLVM: 10.0.0
Default target: arm-unknown-linux-gnueabihf

Still missing the compile date, but it works along with shards 0.15.0.

Benjamin Wade
@RespiteSage
@lebogan Very cool! I'm glad you got it working.
Taupiqueur
@alexherbo2
I think I found a bug in File.match?
File.match? accepts a String or Path as path, but match_single_pattern only accepts String
George Dietrich
@Blacksmoke16
im assuming you get compile time error if you try and use a Path
Taupiqueur
@alexherbo2
yep
it's how I discovered the bug