Thomas Morley <thomasmorle...@gmail.com> writes: > 2015-03-17 22:37 GMT+01:00 Carl Sorensen <c_soren...@byu.edu>:
>> On 3/17/15 3:12 PM, "Thomas Morley" <thomasmorle...@gmail.com> wrote: >> >> > #(vector "p" "i" "m" "a" "c" (markup #:with-color red "remark")) >> >> Why use a vector and vector-ref, instead of just using a list and list-ref? >> > Well, because define-grob-properties.scm states: > (digit-names ,vector? "Names for string finger digits.") > > Though, I have to confess my lack of knowledge here. Why are certain > properties vectors (digit-names, break-align-orders, break-visibility etc)? > What are the advantages/disadvantages? > I don't know. Vector elements can be accessed in constant time. Generally, one uses lists for material that is usually accessed in sequence, and vectors for stuff that is accessed by number and in unpredictable order. It's actually one of the design choices I like for Lua as an extension language: they have only a single data structure ("table") that works reasonably efficiently for almost all use cases (well, excepting frequent single-element insertion/deletion but one can still use an indirection array to emulate singly-linked lists). So the question "what data structure should we represent this data with" never arises. Similarly, they "intern" all their strings meaning that their address is always sufficient for equality comparisons. Basically, they _only_ have what Scheme calls "symbols" and call it "string". Again, this avoids the question "what data type should we represent this textual data with". Scheme has quite more data types and data structures, and it would feel wrong not to choose the most suitable representation for Scheme programming when deciding what data type to employ. -- David Kastrup _______________________________________________ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel