ElementEncodingType and immutable

Jonathan M Davis jmdavisProg at gmx.com
Thu Nov 21 23:54:33 PST 2013


On Friday, November 22, 2013 01:01:52 bioinfornatics wrote:
> hi with this code: http://www.dpaste.dzfl.pl/2f830da1
> I do not understand why alias Char is equal to immutable(char)
> 
> How to fix these issues?

I'm not quite sure which line you're refering to here, but ElementEncodingType 
is going to give the same constness as the elements - e.g. 
ElementEncodingType!string is going to be immutable(char), not char.

Also, you're doing something with AAs, and all keys for AAs are immutable, 
even if you don't explicitly mark them as immutable, so if if the type that 
you're using ElementEncodingType was a key in an AA, that could be your 
problem.

However, the first error that's popping up seems to relate to the fact that 
ranges treat strings as ranges of dchar, not char, so sequence gives you 
letters which are dchar, not char, and then you try and assign it to an AA 
which holds immutable(char) rather than dchar (and the fact that the AA holds 
immutable(char) rather than char might cause further problems with being able 
to reassign anything in the AA - and if it doesn't it's probably due to the AA 
doing casting internally when it shouldn't).

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list