I've always thought that structs could use a 'constructor' format like `%URI("https://elixirforums.com/")`, and it would just be rewritten in code to be `URI.create("https://elixirforums.com/")` *with* auto-requiring of it so macro's work out-right (though that could of course be optional in an actual spec perhaps). I could imagine a Pid being like `%Process.Pid(0, 55, 0)` or so.
However, I'm not sure it really gains much to the language. Sure I don't like the `#...` inspections of things like `PID`'s, but I still wouldn't add the above. Instead I'd standardize on inspections being a representative object, so PID's instead of printing like `#PID<...>` they should print 'as' the fully construction as however they should be constructed, even if it is an IEX only style constructor. On Friday, October 25, 2019 at 7:56:57 AM UTC-6, Ben Olive wrote: > > I really like the idea of a syntax that delegates to a module! > > That would make a pid something like `%Process<0.55.0>` or ` > %Process.Pid<0.55.0>` which is't a big stretch from the current ` > #PID<0.55.0>` > > On Fri, Oct 25, 2019 at 8:49 AM Kelvin Raffael Stinghen < > kelvin....@gmail.com <javascript:>> wrote: > >> > So I really don't think this feature would be usable with sigils. >> >> Yeah, sure, I was just trying to think of examples of the top of my head, >> I’m sure it would still have a lot of limitations, but I think it would be >> worth the try. >> >> > No, they are enforced by the language. >> >> I see. I vote for only caring for the first letter then. >> >> > So this is a separate discussion but what I'd rather see is another >> sigil like mechanism for structs that would make these valid: >> > >> > URI[https://elixir-lang.org]] >> >> Why not actually using sigils for that? With multi letter sigils we could >> do that. Would you want to automatically import that? If that’s the case, >> maybe a better syntax for the feature would be something like: `%URI” >> https://elixir-lang.org”`, so that would delegate the construction to a >> `from_string` function (or macro) on the module for example. >> >> Anyway, I like your idea too, but as you mentioned, that would not >> address my concern, as PIDs are not structs, so I think that multi letter >> sigils would be the way to go for that, since it looks like adding one more >> one letter sigil for it will not get accepted. >> >> Best, >> Kelvin Stinghen >> kelvin....@me.com <javascript:> >> >> On Oct 25, 2019, at 04:00, José Valim <jose...@plataformatec.com.br >> <javascript:>> wrote: >> >> Maybe*. Sigils follow the rules for strings, so they are not really good >> for handling code and this was one of the lessons learned by the >> shorter_maps project. For example, imagine you want to do this: >> >> ~Project{id ~Manager{id}} >> >> It doesn't really work because you have to escape the closing } inside >> the manager. Sure, you could alternate {...} with <...> or something else, >> but that's precisely the point. Sigils are strings, and they are not >> structured text, so you have to escape and handle delimiters accordingly. >> >> The other issue is that sigils are currently lexical, so you would have >> to import the lexical sigil for every struct before your shorter maps >> proposal. So I really don't think this feature would be usable with sigils. >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "elixir-lang-core" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to elixir-l...@googlegroups.com <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/elixir-lang-core/6ACCD0A4-30C6-4E47-852F-FC4A16EB5CB3%40gmail.com >> >> <https://groups.google.com/d/msgid/elixir-lang-core/6ACCD0A4-30C6-4E47-852F-FC4A16EB5CB3%40gmail.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/dfcbf8a8-5f97-425f-88dd-80d317d69650%40googlegroups.com.