Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 08:23
    caspiano edited #10531
  • Dec 08 23:04
    HertzDevil edited #12623
  • Dec 08 22:57
    Blacksmoke16 edited #9745
  • Dec 08 22:57
    Blacksmoke16 labeled #9745
  • Dec 08 22:57
    Blacksmoke16 labeled #9745
  • Dec 08 22:54
    HertzDevil labeled #12828
  • Dec 08 22:54
    HertzDevil labeled #12828
  • Dec 08 22:54
    HertzDevil opened #12828
  • Dec 08 22:34
    straight-shoota edited #12827
  • Dec 08 22:32
    straight-shoota edited #12827
  • Dec 08 22:29
    straight-shoota labeled #12827
  • Dec 08 22:29
    straight-shoota labeled #12827
  • Dec 08 22:29
    straight-shoota opened #12827
  • Dec 08 22:15
    straight-shoota closed #12814
  • Dec 08 17:12
    straight-shoota assigned #12814
  • Dec 08 17:12
    straight-shoota assigned #12813
  • Dec 08 17:12
    straight-shoota assigned #12809
  • Dec 08 17:12
    straight-shoota assigned #12802
  • Dec 08 17:12
    straight-shoota assigned #12797
  • Dec 08 17:12
    straight-shoota assigned #12664
Rishav Sharan
@rishavs
I started there but I couldn't find any method which looks like it does what I need
Nikolaii Lodenos
@lodenos

Good Evening form LDN :)
I try to do that but I’ve 

 20 | {% methods = method_listing(descriptions) %}
                   ^-------------
Error: undefined macro method: 'method_listing'

This is the code

macro method_listing(descriptions)
  %methods = [] of String
  {% for description in descriptions %}
    {% for key in description["methods"] %}
      %methods << %key
    {% end %}
  {% end %}
  %methods.uniq!
end

macro method_switch(descriptions)
  {% methods = method_listing(descriptions) %}
end

Do u have some Idea ???

Ary Borenszweig
@asterite
Yes. You can't call a macro from inside a macro.
George Dietrich
@Blacksmoke16
Does this even need to be a macro?
Nikolaii Lodenos
@lodenos
Hum I see but the code can be more reable because I try to refactor 300 lignes code of pure macro
@Blacksmoke16 It’s a exemple of my issue
George Dietrich
@Blacksmoke16
could prob do like method_listing {{descriptions}}
but my question still stands, dont really need a macro to do this type of thing
Nikolaii Lodenos
@lodenos
Ok I understand It’s was an exemple a somthing more complicated
George Dietrich
@Blacksmoke16
fair enough
Nikolaii Lodenos
@lodenos
How can we organised a really big macro ?
like 300 lines
George Dietrich
@Blacksmoke16
use variables, proper indenting etc
got a link to it?
It’s Horrible how it’s writed
I don’t understand my own code
George Dietrich
@Blacksmoke16
oo another framework :P
Nikolaii Lodenos
@lodenos
it’s more a library than a framework
George Dietrich
@Blacksmoke16
unfortunately there just isnt a good way to have clean macro code because you can't define reusable macro methods (yet?)
could probably just add more comments or something, id also suggest writing some tests, be easier to ensure its working at least
Nikolaii Lodenos
@lodenos
Right, thx for the anser, I hope one day we can reuse macro methods can be really powefull
George Dietrich
@Blacksmoke16
have you considered using annotations instead of the hash?
@[Cocaine::Route(path: "/", verb: "GET")]
def controller_index(context : HTTP::Server::Context, params : Cocaine::Param)
  context.response.content_type = "text/plain"
  context.response.print "Hello world, got #{context.request.path} !"
end

@[Cocaine::Route(path: "/user/:id", verb: "GET")]
def controller_user(context : HTTP::Server::Context, params : Cocaine::Param)
  context.response.content_type = "text/plain"
  context.response.print "Hello world, got #{context.request.path} !"
end


################################################################################
# Server
################################################################################

server = HTTP::Server.new { |context| Cocaine.match_endpoint context }
server.listen "0.0.0.0", 5000
Nikolaii Lodenos
@lodenos
I never try that on my own code
George Dietrich
@Blacksmoke16
looks like a good use case for them. However the downside is there isn't a way to iterate over all methods with an annotation, so would need to think of a way around that.
but :shrug: just a thought
Nikolaii Lodenos
@lodenos
With this lib I’ve only one object a bit useless
George Dietrich
@Blacksmoke16
hm?
Nikolaii Lodenos
@lodenos
George Dietrich
@Blacksmoke16
fair enough
good luck
Nikolaii Lodenos
@lodenos
I know XD
George Dietrich
@Blacksmoke16
benchmarks like that are mainly just testing the router, is fairly easy to have a faster framework, but then the framework itself isn't much of a framework
pretty sure all the crystal ones on there are using HTTP::Server, so to be faster than that you might need to get creative
https://github.com/S-YOU/h2o.cr such as binding to a c http server like this one did
Nikolaii Lodenos
@lodenos
Learn to optimize to the maximum helps to understand in detail the suptiles of the language and its conception. I can imagine.
didactic-drunk
@didactic-drunk
Why doesn't Bytes.new call GC.malloc_atomic? How does it get it's memory or any other Pointer.malloc? I'm attempting to track malloc usage and my monkey patches don't run.
@didactic-drunk: it seems that the memory allocated for pointers isn't assumed to be atomic then
atomic, as I understand, being a declaration that that memory will not contain GC-relevant pointers
for arrays a choice was made to always assume that their memory will not contain undeclared pointers, that's where u get malloc_atomic, but it's not used always
Quinton Miller
@HertzDevil
Jonathan Silverman
@mixflame
if anyone is into amber, can you please review pull request #1265 on amberframework/amber and tell me if you can spot any weaknesses? it's a multichannel redis adapter for websockets
George Dietrich
@Blacksmoke16
your link broke ^
didactic-drunk
@didactic-drunk
I monkey patched GC.malloc* and it segfaults only with -Dpreview_mt when calling an empty function. https://github.com/didactic-drunk/fiber_stats.cr/pull/1#discussion_r665800802
From IRC (bridge bot)
@FromIRC
<postmodern> so what is the difference between .as(Int32) and .to_i32 ?
George Dietrich
@Blacksmoke16
the former just tells the compiler to treat the values as an int32 without actually doing the conversion
i.e. pretty sure .as wouldn't handle over/underflows, so id deff use .to_i32, or really just .to_i