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
We are seeing a lot of warning logs like this:
navigate event to "https://someurl" failed because you are redirecting across live_sessio...
New
Other Trending Topics
Looking for an elixir job.
James Schiiller
Detroit, Michigan
Travel/relocate or work remotely
Over 20 years of professional programming...
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
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
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
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
- #blog-post
- #elixirconf-us
- #elixir-ls
- #ai
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (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.