edvardo1
Hello, I’ve found an interesting non-backwards-compatible change in Elixir 1.20.
For context: There exists a project called PolyHok, which is a DSL that is embedded in Elixir, its aim is to make GPU programming easier in Elixir, I am one of the people participating in the development of this DSL.
The main way you’re supposed to use it is by using the PolyHok.defmodule macro, which basically overloads the defmodule construct, it processes the defk (define kernel) and defd (define device function) expressions, takes them out of the module body, then process that module normally. Now, I know that that’s not the most orthodox way to do it, as Nx doesn’t do it like that, but it worked in previous versions. Here’s an example:
require PolyHok
PolyHok.defmodule Wow do
defk myk(a) do
a[1] = 9.2
end
def f() do
2
end
end
In Elixir 1.19.6, it functions normally and you can use the defk definition for whatever you wanna use it for, but for Elixir 1.20 and later, it spits out this error:
error: undefined function defk/2 (there is no such import)
│
4 │ defk myk(a) do
│ ^
│
└─ elixir/examples.exs:4:3: Wow (module)
** (CompileError) elixir/examples.exs: cannot compile module Wow (errors have been logged)
Does anyone why this happens, why the behavior was changed, and if there is an easy way to fix this?
Links for the curious:
PolyHok website: PolyHok: GPGPU in Elixir []
PolyHok repository: GitHub - lups-ufpel/poly_hok: PolyHok DSL repository. · GitHub
Trending in Troubleshooting
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixir-ls
- #elixirconf-us
- #ai
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming









