Просто некоторый надоедливый факт.
Сравним:
vs
Когда пишу на c#, чувствую себя очень неуютно… Все эти лишние вещи, которые надо сначала писать, а потом читать, которые путаются, лезут в глаза, вызывают ошибки компиляции… В любом случае, syntactic sugar matters, и лисп самый «сахарный» в этом отношении.
Сравним:
public class TextTag
{
private int begin;
public int Begin
{
get { return begin; }
set { begin = value; }
}
private int length;
public int Length
{
get { return length; }
set { length = value; }
}
private Dictionary<string,object> attributes = new Dictionary<string,object>();
public object this[string attributeName]
{
get { return attributes[attributeName]; }
set
{
if (attribues.ContainsKey(attributeName))
attributes[attributeName] = value;
else
attributs.Add(attributeName,value);
}
}
public TextTag(int begin, int length)
{
this.begin = begin;
this.length = length;
}
}
new TextTag(0,15);
vs
(defclass tag ()
((begin
:accessor tag-begin
:type integer
:initarg :begin)
(length
:accessor tag-length
:type integer
:initarg :length)
(attributes
:type hash-table
:initform (make-hash-table))))
(defun attribute-of (tag attribute-name)
(gethash attribute-name (slot-value tag 'attributes)))
(defun set-attribute-of (tag attribute-name attribute-value)
(setf (gethash attribute-name (slot-value tag 'attributes)) attribute-value))
(defsetf attribute-of set-attribute-of)
(make-instance 'tag :begin 0 :length 15)
Когда пишу на c#, чувствую себя очень неуютно… Все эти лишние вещи, которые надо сначала писать, а потом читать, которые путаются, лезут в глаза, вызывают ошибки компиляции… В любом случае, syntactic sugar matters, и лисп самый «сахарный» в этом отношении.