dogweather
Following the Adding Pages tutorial, I addded a new route, without creating the controller:
get("/hello", HelloController, :index)
And this compiles w/ no warnings! Even after doing mix clean ; mix compile. However, I can get a compile error if I use an unknown lowercased keyword in router.ex:
snackTime
But the following inside a router.ex scope compiles fine:
SnackTime
Is there some kind of lack of type safety for module names?
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #security











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
OvermindDL1
Well first there is no static typing in elixir. Second, module names are just atom, no different from any other atom:
So the only way to check it would be to actually call something on it (
module_info/0is a common thing to test). What thegetis basically doing is just taking the atom you pass in for the module and the atom you pass in for the function (function names are just atoms too) and basically calling it likeapply(moduleAtom, functionAtom, [conn, params]).dogweather
Thanks!
I’m seeing the difference outside of the
get(), however. E.g., after thedefmodule’send:Are you saying, that
NonexistentThingis simply not evaluated? Optimized out before it’s linked?(Indeed, I see that I get this behavior in a simple
mix newproject.)Ankhers
Simply calling
NonexistentThingisn’t doing anything. It is just an atom. There is nothing to evaluate. It does not know that you are trying to reference a module. It is just like any other literal. You would not get an error if you replaced it with4. If instead you tried usingNonexistentThing.foo, you should get an error stating that it does not exist.On the other hand,
nonexistentThingis trying to reference a variable that does not exist.dogweather
So it could be seen as a language syntax issue. I think it’d be hugely beneficial to get warnings for mis-spelled symbols. I hadn’t realized that an uppercase “bare word” is accepted as a valid expression.
dogweather
I imagine that this alternate API would provide the kind of compiler checks I’m thinking about:
…using capture to pass in an actual function instead of stringly typed values. TBH, I like it - it’s more obvious what
get()is doing.michalmuskala
The problem with this syntax is that it would introduce a compile-time dependency on the
HelloControllermodule. You don’t want all of your controllers recompiled when you change the router.peerreynders
The MFA pattern (module,function,arguments) is quite pervasive in BEAM languages. For example compare:
Kernel.spawn/3Kernel.spawn/1and as already mentioned
Kernel.apply/3So while
may look strange coming from other languages, it’s not unusual in OTP to assemble function invocations (or process initializations) as MFA triplets.
Not to be confused with the
mfa()type which is actually{module(), atom(), arity()}.NobbZ
Also, will this not create a lot of functions in the router module?
As far as I remember anonymous functions in the BEAM are just compiled into regular functions with a mangled name in the owning module?
dogweather
Acutally, it’s all too familiar, coming from Ruby and Rails. I was hoping to get a little more help from the compiler when possible.
OvermindDL1
Hear hear! If only Elixir had static typing. ^.^;