Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

No del function for get_global_map

16 views
Skip to first unread message

Hakan Kjellerstrand

unread,
Jan 19, 2025, 12:39:23 PMJan 19
to Picat
get_global_map()  does not support the del/1 function. Since it is a map, I would expect is should support del/1..

Plain maps:
"""
Picat> X=new_map(), X.put(a,1),X.put(b,2),X.del(a)      
X = (map)[b = 2]
yes
"""

But for get_global_map an error is thrown:
"""
Picat> X=get_global_map(), X.put(a,1),X.put(b,2),X.del(a)

*** error(hashtable_expected($ghshtb(43,0)),hashtable_del($ghshtb(43,0),a))
"""

As for get_table_map()
"""
Picat> X=get_table_map(), X.put(a,1),X.put(b,2),X.del(a)

*** error(hashtable_expected($thshtb(43,0)),hashtable_del($thshtb(43,0),a))
"""

Though it works for get_heap_map()
"""
Picat> X=get_heap_map(), X.put(a,1),X.put(b,2),X.del(a)  
X = (map)[b = 2]
yes
"""


Best,

Hakan

Oisín Mac Fhearaí

unread,
Jan 19, 2025, 7:14:42 PMJan 19
to Picat
On a slightly tangential note, I was surprised to discover that using a heap map to "pass" contextual data (e.g. a maze grid) into action predicates was much faster than using a global heap map. I expected a global map would be faster since it avoids the backtracking system completely. What would cause this? I was thinking maybe a cache locality effect but that feels unlikely.

Neng-Fa Zhou

unread,
Jan 20, 2025, 12:01:34 PMJan 20
to Picat
Thank you, Hakan, for reporting the missing del/2 built-in on table and global maps. I have fixed the issue. You can confirm it in version 3.8b5.

Regarding Oisin's observation, I never have context data passed to tabled predicates, including planner predicates, as maps, because maps can be destructively updated by the built-in put/3, while tabled data can never be destructively updated. Even if a map is not destructively updated, it needs to be copied to the table area, including the bucket table. If a global map is used, then it may need to be duplicated in the code area and the table area. I normally have context data as arrays to tabled predicates. If symbols are used as keys, I first have them converted to integer indexes.

Cheers,
NF


--
You received this message because you are subscribed to the Google Groups "Picat" group.
To unsubscribe from this group and stop receiving emails from it, send an email to picat-lang+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/picat-lang/310673c9-4e69-43d7-855f-82dfa652d446n%40googlegroups.com.

Hakan Kjellerstrand

unread,
Jan 20, 2025, 3:44:49 PMJan 20
to Neng-Fa Zhou, Picat
Thanks for the fix, Neng-Fa. 

I can confirm that this works now. Also, I did my usual benchmark tests, and no new issues were found.

Best,

Hakan

You received this message because you are subscribed to a topic in the Google Groups "Picat" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/picat-lang/anu7s-t2KLE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to picat-lang+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/picat-lang/CAFOC6HQKhfgs9u9pE5voFXrVqmySRqECTors%3Dp19gqyg7%2B4W%3DA%40mail.gmail.com.


--
Reply all
Reply to author
Forward
0 new messages