What languages ​​provide the use of object literals?

What languages ​​provide the use of object literals? (Or in what languages ​​could you easily mimic them?) Can you give some sample code?

Starting with the obvious javascript snippet:

var someObj = { someProperty: 123, someFunction: function() { alert('hello!'); } }; 
+4
source share
2 answers

If you replace the object with "term", then Prolog will do this naturally (in fact, there is no other way to build the object). Here is an example with binary trees:

 % find a node in List with a nil left child and call its rightmost grandchild X member(node(nil,node(_,X)), List). 

Lisp, and the circuit also has some interesting features in this area, in particular, quoting and half quoting:

 ;; construct right-leaning binary tree with x as the rightmost grandchild `(nil . (nil . ,x)) 

Almost all functional programming languages ​​have copied this in some form.

+2
source

Checkout Anonymous C # Types

 var Customer = new { Company = "AgileApps", Website = "http://www.agileapps.co.uk", Name = "Big Al", Entered = DateTime.Now }; 
+4
source

Source: https://habr.com/ru/post/1333887/


All Articles