Date & Time Literals
Published: 2021-09-16
Discussion on:
Acmion (on this website),
or
Reddit.
Nearly all programming languages feature literals for a multitude of data types, but support for date and time literals is very rare at the least. However, such literals could provide certain benefits.
Some examples of literals used in "real world" programming languages:
int_literal = 0
float_literal = 0.0f
string_literal = "Hello world"
list_literal = [ 1, 2, 3 ]
object_literal = { a = 1, b = 2, c = "hello" }
A potential date and time literal syntax:
time = <18:12:57.89>
date = <2021-09-16>
time_zone = <+01:00>
time_zone_region <us/pacific>
date_time = <2021-09-16 18:12:57.89>
date_time_zone = <2021-09-16 18:12:57.89 +01:00>
date_time_zone_region = <2021-09-16 18:12:57.89 us/pacific>
interpolated_date_time_zone_region = <@date @time @time_zone_region>
The motivation behind this is that one would not have to depend on certain imported or global functions or constructors to create relatively widely used data types. For example, few if any programming languages, require the following declaration for integers: i = new int(1)
. Additionally, in the name of consistency one could define literals for all of the most basic data types (ints, floats, lists, dicts, objects, etc.).
This would not only be a nice feature in a programming language, but also in a separate serialization format. For example, how does JSON serialize dates? The answer is as strings, but this is quite an error prone approach. Certain languages even default to using strings as dates (or maybe its just the programmers that use strings for convenience), which is also quite problematic.
Maybe this will someday be implemented more widely in existing programming languages.
Discussion
Discuss this post here! You may also discuss it on or Reddit.
hafTaitte
This condition may be congenital appear at birth can occur with aging or may be associated with stroke cerebrovascular accident cranial nerve damage and other neurologic disorders. Rqreze https://oscialipop.com - cheap cialis This type of acidosis is usually caused when the body is unable to remove enough carbon dioxide through breathing. Bryvma <a href="https://oscialipop.com">Cialis</a> Wkmbqj Tocita https://oscialipop.com - cialis generic online Xwtltl Amoxicillin For Dogs Colds
skyreveryres
https://www.skyrevery.ru/airplanes/pilatus-pc-12/ - Частный самолет Pilatus PC-12/47E (NG) (Пилатус 12) - SkyRevery - подробнее на нашем сайте https://skyrevery.ru - skyrevery.ru https://skyrevery.ru/ - Аренда частного самолета с экипажем в компании SkyRevery – это выбор тех, кто ценит свое время и живет по своему расписанию! Аренда частного самолета помогает экономить самый важный ресурс – время. Арендовав частный самолет, именно Вы решаете, когда и куда полетите. Для выполнения чартерных рейсов мы предлагаем частные самолеты иностранного производства, гарантирующие высокий уровень комфорта и безопасности полета. Внимательные бортпроводники и высокопрофессиональные пилоты сделают Ваш полет максимально приятным и удобным. Когда Вам нужна https://skyrevery.ru/ - аренда самолета срочно, мы можем организовать для Вас вылет по готовности от 3 часов с момента подтверждения.
Reply to Comment
Report Comment