beno
There appears to be no way to escape whitespace in word lists, so sigil_w (and sigil_W) can only be used for lists of single words. Of course that is its main purpose, but to me it would be much more useful if it would allow something like:
~w[foo\ bar baz] => [“foo bar”, “baz”]
Is there any reason it doesn’t work this way?
Trending in Proposals: Ideas
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
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
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
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #phoenix_html
- #iex
- #graphql
- #ai
- #genstage
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All Posts (oldest first)
- Show All Posts (newest first)
fuelen
~wbecause it is a list or words."foo bar"is not a wordsodapopcan
I like to think of these sigils as a way to communicate intent to the reader (the list should only be made up of single string tokens) rather than a shorthand for the writer. I never use the
amodifier for this reason, as well as others.adamu
I just never use them. It doesn’t take much effort to write out a list, and it’s completely unambiguous when read - which is many more times than written.
beno
My point is we are not always in control of the contents of these lists. Things like paths names or spreadsheet headers can easily contain spaces, and whenever this occurs the sigil needs to be replaced by traditional lists. I would love to avoid that by being able to escape whitespace.
sodapopcan
That’s my point, though: if it’s only incidental that the entries are single words and could be more, I don’t bother using the sigil version. I understand the pain, though.
LostKobrakai
sigil_wand it’s uppercase counterpart are macros. Their values need to be compile time known.This is not the tool to use for user input or anything you don’t know what it is.
beno
No the contents are static, but out of our control.
LostKobrakai
You’re still free to use a more appropriate tool to parse content you cannot make sure is going to be a list of words. These sigils really are conveniences for when you’re dealing with a list of words and you don’t want to type that much. You’re not dealing with a list of words as it seems, so you want to use something else.
beno
I am dealing with lists. E.g. in the case of paths, the System.cmd() function accepts a list of arguments, often containing pathnames. I could give other examples, but trust me I have encountered it enough to warrant this post. Even using a variable doesn’t work:
LostKobrakai
A list of words is a subset ot all list. You’re clearly not dealing with just that subset.
If you’re dealing with CLI arguments
OptionParsermight be the more appropriate tool to use.