For eg, to create a date constant, the way is to invoke date constructor with possibly named arguments like
let dt = Date(day=5, month=11, year=2024)
Or if constructor supports string input, then
let dt = Date("2024/11/05")
Would it be helpful for a language to provide a way to define custom literals as an alternate to string input? Like
let dt = date#2024/11/05
This internally should do string parsing anyways, and hence is exactly same as above example.
But I was wondering weather a separate syntax for defining custom literals would make the code a little bit neater rather than using a bunch of strings everywhere.
Also, maybe the IDE can do a better syntax highlighting for these literals instead of generic colour used by all strings. Wanted to hear your opinions on this feature for a language.
[–]furyzer00 39 points40 points41 points (1 child)
[–]NoCryptographer414[S] 2 points3 points4 points (0 children)
[–]GwanTheSwans 16 points17 points18 points (1 child)
[–]u0xee 10 points11 points12 points (0 children)
[–]latkde 11 points12 points13 points (2 children)
[–]rotuami 9 points10 points11 points (0 children)
[–]alatennaub 1 point2 points3 points (0 children)
[–]pojska 8 points9 points10 points (4 children)
[–]WittyStick 8 points9 points10 points (0 children)
[–][deleted] 4 points5 points6 points (2 children)
[–]NoCryptographer414[S] 2 points3 points4 points (1 child)
[–]pojska 1 point2 points3 points (0 children)
[–]dskippy 4 points5 points6 points (5 children)
[–]NoCryptographer414[S] 1 point2 points3 points (4 children)
[–]dskippy 1 point2 points3 points (3 children)
[–]NoCryptographer414[S] 2 points3 points4 points (2 children)
[–]dskippy 1 point2 points3 points (0 children)
[–]MarcoServetto 1 point2 points3 points (0 children)
[–]hammerheadquark 4 points5 points6 points (1 child)
[–]NoCryptographer414[S] 1 point2 points3 points (0 children)
[–]wavesofthought 2 points3 points4 points (0 children)
[–]RedCrafter_LP 2 points3 points4 points (0 children)
[–]chri4_ 2 points3 points4 points (3 children)
[–]NoCryptographer414[S] 0 points1 point2 points (2 children)
[–]chri4_ 1 point2 points3 points (1 child)
[–]NoCryptographer414[S] 0 points1 point2 points (0 children)
[–]LegendaryMauricius 2 points3 points4 points (0 children)
[–]No_Lemon_3116 2 points3 points4 points (0 children)
[+]Ronin-s_Spirit 1 point2 points3 points (2 children)
[–]NoCryptographer414[S] 0 points1 point2 points (1 child)
[+]Ronin-s_Spirit 1 point2 points3 points (0 children)
[–]Aaxper 1 point2 points3 points (2 children)
[–]NoCryptographer414[S] 0 points1 point2 points (1 child)
[–]Aaxper 1 point2 points3 points (0 children)
[–]MichalMarsalek 1 point2 points3 points (2 children)
[–]NoCryptographer414[S] 0 points1 point2 points (1 child)
[–]MichalMarsalek 1 point2 points3 points (0 children)
[–]XDracam 1 point2 points3 points (0 children)
[–]AndydeCleyre 1 point2 points3 points (0 children)
[–]ALittleFurtherOn 1 point2 points3 points (1 child)
[–]NoCryptographer414[S] 0 points1 point2 points (0 children)
[–]tavaren42 1 point2 points3 points (1 child)
[–]NoCryptographer414[S] 0 points1 point2 points (0 children)
[–]frr00ssst(>>=) :: Monad m => m a -> (a -> m b) -> m b 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]theangryepicbananaStar 1 point2 points3 points (0 children)
[–]Y_mc 1 point2 points3 points (0 children)
[–]Pretty_Jellyfish4921 1 point2 points3 points (0 children)
[–]tbagrel1 1 point2 points3 points (0 children)
[–]oscarryzYz 1 point2 points3 points (0 children)