Immutability and other attributes, please review
Jacob Carlborg
doob at me.com
Fri Jun 15 01:41:47 PDT 2012
On 2012-06-15 10:30, dennis luehring wrote:
> i think he needs to - else he encapsulate the float into an struct which
> is then also on the heap
>
> (ast/whatever)
> nodex -> float
> nodey -> string
> nodez -> int
> nodew -> double
>
> etc.
>
> in this example a node can contain from n types values - how would you
> solve that? or better what is the smallest(maybe fastest) representation
>
> there need to be a queryable tree in the end - so there is a need to
> hold the values - yes he can copy by value - but into whom?
>
> in the end it will be an variant-like type (with members for each type)
> on heap - whichs is not that good because that will cost much more mem
>
> or something like an class FloatValue -> NodeValue -> Value oop-hierachy
> whichs also will get onto the heap
>
> i would try to use something like an base-types pool for all the small
> float,double,int,string etc values... and pointer to this pool - or just
> use the heap :)
>
Ah, I see.
--
/Jacob Carlborg
More information about the Digitalmars-d-learn
mailing list