[Harbour] HASH AUTOADD

Mindaugas Kavaliauskas dbtopas at dbtopas.lt
Thu Oct 4 08:11:04 EDT 2007


Przemyslaw Czerpak wrote:
> The last place where we have one #ifdef HB_COMPAT_XHB in core code
> is source/vm/hash.c and default AUTOADD setting for hash items.
> 
> I'd like to remove it and also change a little bit default hash
> behavior and hash functions. Now after some expieriences with
> current code and user feedback I think that we should set
> HB_HASH_AUTOADD_ASSIGN by default - it's default in most of other
> languages f.e. PHP and seems to be natural setting expected by
> most of users.
> 
> The second thing I'd like to change is AUTOADD mode.
> Now we can set 4 states for AUTOADD in HASH item:
>     HB_HASH_AUTOADD_NEVER
>     HB_HASH_AUTOADD_ASSIGN
>     HB_HASH_AUTOADD_ACCESS
>     HB_HASH_AUTOADD_ALWAYS = (HB_HASH_AUTOADD_ASSIGN + HB_HASH_AUTOADD_ACCESS)
> We can eliminate ACCESS flag by adding special meaning to DEFAULT hash
> value. When it's set then autoadd in ACCESS is possible - if not then
> it's forbidden.
> 
> I also do not know think that someone uses only ACCESS autoadd mode
> without ASSING. IMHO we can reduce possible autoadd states to:
>     HB_HASH_AUTOADD_NEVER
>     HB_HASH_AUTOADD_ASSIGN
>     HB_HASH_AUTOADD_ALWAYS
> 
> After above we can elininate these flags and define that:
> 1. AUTOADD is possible or not (controll by logical value)
> 2. AUTOADD when enabled works always for ASSING operation
> 3. When DEFAULT value is set then AUTOADD when enabled works
>    also for ACCESS

Hi,


so, by default this new logical AUTOADD setting will be TRUE (like 
written in the top of your mail)?

It's OK for me.

Just one question. If AUTOADD is FALSE and default value is set, it will 
work like current HB_HASH_AUTOADD_ACCESS, or AUTOADD flag has higher 
priority and it will work like HB_HASH_AUTOADD_NEVER?

Default value setting function should be changed also, perhaps into two: 
HB_HSetDefault(), HB_HGetDefault(). The problem is, if I want to enable 
AUTOADD on ACCESS by setting default value, and later I want to switch 
AUTOADD on ACCESS off. I should clear default value. Current 
HB_HDefault(hHash) is not OK because it works as GetDefault. 
HB_HDefault(hHash, NIL) is also not good, because default value could be 
NIL. An alternative to this could be current HB_HDefault() and new 
HB_HClearDefault(hHash), but I see HB_HGetDefault()/HB_HSetDefault() 
more elegant. HB_HSetDefault() can return hHash if someone will want to use:
   HB_HAutoAdd(HB_HSetDefault(hHash), .F.)


Best regards,
Mindaugas







More information about the Harbour mailing list