Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 20:54
    oprypin edited #12545
  • 17:04
    straight-shoota edited #12530
  • 16:06
    straight-shoota labeled #12550
  • 16:03
    straight-shoota milestoned #12549
  • 16:03
    straight-shoota milestoned #12549
  • 16:01
    Hadeweka opened #12550
  • 16:01
    Hadeweka labeled #12550
  • 14:12
    straight-shoota labeled #12549
  • 14:12
    straight-shoota labeled #12549
  • 14:12
    straight-shoota labeled #12549
  • 14:12
    straight-shoota opened #12549
  • 13:54
    straight-shoota closed #12282
  • 13:28
    straight-shoota labeled #12548
  • 13:28
    straight-shoota labeled #12548
  • 13:28
    straight-shoota opened #12548
  • 13:28
    straight-shoota labeled #12548
  • 11:06
    straight-shoota edited #12547
  • 11:05
    straight-shoota opened #12547
  • 11:05
    straight-shoota labeled #12547
  • 11:05
    straight-shoota labeled #12547
Ghost
@ghost~55586c4815522ed4b3e08557
one that accept a block and one who dosn't @NARKOZ
look the second, there is a yield that will inline the passed block
Nihad Abbasov
@NARKOZ
how comes that methods don't get overwritten?
Ghost
@ghost~55586c4815522ed4b3e08557
because a method that accept a block and one that doesn't are 2 different methods, they don't override each other, even though they have the same name
@bew I was dumb :(
From IRC (bridge bot)
@FromIRC
<Groogy> And back from lunch
<Groogy> it would be nice though if the number could work as any other number in the example I showed
<Groogy> If you switch out the NUMBER constant for the N generic argument it works as expected
Ghost
@ghost~55586c4815522ed4b3e08557
@straight-shoota it got me more than once!
From IRC (bridge bot)
@FromIRC
<Groogy> also thanks Yxhuvud, commited fix now
Johannes Müller
@straight-shoota
@bew Where did you find this final word?
I understood @bcardiff in https://github.com/crystal-lang/crystal/issues/236#issuecomment-302734259 (3) as it would be preferable to change precedence
this aspect got lost though in the remainder which was about top level macros
Ghost
@ghost~55586c4815522ed4b3e08557
@straight-shoota right, that was what I remembered, but can't find it again
Serdar Dogruyol - Sedo セド
@sdogruyol
Morning everyone :)
From IRC (bridge bot)
@FromIRC
<Groogy> It's midday but okay :⁠P
Serdar Dogruyol - Sedo セド
@sdogruyol
haha yeah :D
Ghost
@ghost~55586c4815522ed4b3e08557
Midday everyone then :P
@straight-shoota I edited my comment to remove the "final word"
Johannes Müller
@straight-shoota
^^
Ghost
@ghost~55586c4815522ed4b3e08557
@straight-shoota if like you say, all your examples should call the method, how do we do to call the macro foo? Do we need to use special syntax?
Bar Hofesh
@bararchy
Head is broken on Arch Linux ?
g++ -c -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt  -o src/llvm/ext/llvm_ext.o src/llvm/ext/llvm_ext.cc `/usr/bin/llvm-config --cxxflags`
cc -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -fPIC  -D_FORTIFY_SOURCE=2  -c -o src/ext/sigfault.o src/ext/sigfault.c
ar -rcs src/ext/libcrystal.a src/ext/sigfault.o
./bin/crystal build --release  -o .build/crystal src/compiler/crystal.cr -D without_openssl -D without_zlib
crystal: /var/cache/omnibus/src/llvm/llvm-3.8.1.src/lib/CodeGen/LexicalScopes.cpp:160: llvm::LexicalScope* llvm::LexicalScopes::getOrCreateRegularScope(const llvm::DILocalScope*): Assertion `cast<DISubprogram>(Scope)->describes(MF->getFunction())' failed.
/tmp/yaourt-tmp-unshadow/aur-crystal-git/src/crystal-0.23.1-3/bin/crystal: line 102:   805 Aborted                 (core dumped) "$INSTALL_DIR/embedded/bin/crystal" "$@"
make: *** [Makefile:117: .build/crystal] Error 134
Ghost
@ghost~55586c4815522ed4b3e08557
Can you try to build manually?
kipar
@konovod
@bararchy same error message is in #4719 with Ubuntu. Don't know the cause.
Johannes Müller
@straight-shoota
@bew you can call it like a class method: https://carc.in/#/r/2dsw
From IRC (bridge bot)
@FromIRC
<Groogy> @bararchy you building with the aur package crystal-git?
<Groogy> if you have bauerbill you can just do bb-wrapper --aur -S crystal-git
<Groogy> and that should just install latest for you
<Groogy> at least I have 0.23.0+13 from (2017-07-17) installed through that
Ghost
@ghost~55586c4815522ed4b3e08557
@straight-shoota but this makes that you need to know where the macro is defined, and it breaks the logic of include-ing a module with methods and macros and being able to simply call them
Johannes Müller
@straight-shoota
If self.class.my_macro worked this shouldn't be a problem I think
Ghost
@ghost~55586c4815522ed4b3e08557
this is quite ugly.. IMO
Johannes Müller
@straight-shoota
True, but currently you need to prefix method calls with self. as well, so it's not that different
at least if macros are visible but methods have precedence
Ghost
@ghost~55586c4815522ed4b3e08557
also, self.class is the runtime class of the instance, the compiler who needs to find which macro to call can't know what you want I think
Johannes Müller
@straight-shoota
I'm currently working on refactoring Kemal to use encapsulation instead of global state. There I have a macro Kemal::Base.get and an instance method Kemal::Base#get. Currently, when I call get from inside a instance method, it calls the macro, but I would expect it to call the instance method. And it's ugly if you have to invoke the instance method with explicit receiver...
Ghost
@ghost~55586c4815522ed4b3e08557
you could use with my_obj yield to specify a strong implicit receiver
Johannes Müller
@straight-shoota
this only works with a block, not if you're directly inside a method
Ghost
@ghost~55586c4815522ed4b3e08557
what is the macro get for ?
Cris Ward
@crisward

@straight-shoota If you're doing that, FWIW perhaps look at how express.js does it. Ie.

var app=new Express();
app.get("/",function(res,res){
  res.send("hello")
})
app.listen(3000)

could become

app = Kemal.new
app.get "/" do |env|
  "hello"
end
app.run
Ghost
@ghost~55586c4815522ed4b3e08557
how do you want the users of your lib to use either the method or the macro?
The macros create a DSL at class scope, the method at instance scope
@crisward this is already possible in my branch
an alternative is
class MyApp < Kemal::Application
  get "/" do |env|
    "hello"
  end
end
MyApp.run
Ghost
@ghost~55586c4815522ed4b3e08557
should this call the macro or the method? can you show an example using the 2?
Johannes Müller
@straight-shoota
class MyApp < Kemal::Application
  get "/" do |env|
    "hello"
  end
  def initialize_instance_routes
    get "/foo" do |env|
      "bar"
    end
  def
end
app = MyApp.new
app.initialize_instance_routes
app.run
Line 2 targets the maro, line 6 the instance method
Ghost
@ghost~55586c4815522ed4b3e08557
I don't get the use case of instance routes, but an idea of impl could be:
class MyApp < Kemal::Application
  get "/" do |env|
    "hello"
  end

  # `instance_routes` could be a macro that will define the `initialize_instance_routes` method
  instance_routes do # Here using `with .. yield`, the instance routes can be configured with another DSL (could be methods, .. whatever)
    get "/foo" do |env|
      "bar"
    end
  end
end
app = MyApp.new
app.initialize_instance_routes
app.run