DictPop¶
Removes an entry and returns its value.
Declaration¶
Syntax¶
DictPop(expr a, expr key, ttype type, expr? value)
Arguments¶
Argument |
Description |
|---|---|
|
the dictionary. |
|
the key to remove. |
|
the value type of the dictionary. |
|
the compile time value of the expression, when the frontend could fold it; |
Return values¶
The value of the expression.
Description¶
d.pop(k). Removing a key the dictionary does not hold is an error at run
time.
Examples¶
(DictPop
:a (Var
:v (SymbolRef 1 "d")
)
:key (IntegerConstant
:n 1
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:type (Real
:kind 4
)
:value nil
)
It comes from this complete ASR text document:
(TranslationUnit
:symtab (SymbolTable
:id 0
:symbols {
"main" (Program
:symtab (SymbolTable
:id 1
:symbols {
"d" (Variable
:parent_symtab 1
:name "d"
:dependencies []
:intent :Local
:symbolic_value nil
:value nil
:storage :Default
:type (Dict
:key_type (Integer
:kind 4
)
:value_type (Real
:kind 4
)
)
:type_declaration nil
:abi :Source
:access :Public
:presence :Required
:value_attr false
:target_attr false
:contiguous_attr false
:bindc_name nil
:is_volatile false
:is_protected false
:pass_attr :NotMethod
:self_argument nil
:codims []
)
"i" (Variable
:parent_symtab 1
:name "i"
:dependencies []
:intent :Local
:symbolic_value nil
:value nil
:storage :Default
:type (Integer
:kind 4
)
:type_declaration nil
:abi :Source
:access :Public
:presence :Required
:value_attr false
:target_attr false
:contiguous_attr false
:bindc_name nil
:is_volatile false
:is_protected false
:pass_attr :NotMethod
:self_argument nil
:codims []
)
"p" (Variable
:parent_symtab 1
:name "p"
:dependencies []
:intent :Local
:symbolic_value nil
:value nil
:storage :Default
:type (Logical
:kind 4
)
:type_declaration nil
:abi :Source
:access :Public
:presence :Required
:value_attr false
:target_attr false
:contiguous_attr false
:bindc_name nil
:is_volatile false
:is_protected false
:pass_attr :NotMethod
:self_argument nil
:codims []
)
"x" (Variable
:parent_symtab 1
:name "x"
:dependencies []
:intent :Local
:symbolic_value nil
:value nil
:storage :Default
:type (Real
:kind 4
)
:type_declaration nil
:abi :Source
:access :Public
:presence :Required
:value_attr false
:target_attr false
:contiguous_attr false
:bindc_name nil
:is_volatile false
:is_protected false
:pass_attr :NotMethod
:self_argument nil
:codims []
)
}
)
:name "main"
:dependencies []
:body [
(Assignment
:target (Var
:v (SymbolRef 1 "d")
)
:value (DictConstant
:keys [
(IntegerConstant
:n 1
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
]
:values [
(RealConstant
:r 1.5
:type (Real
:kind 4
)
)
]
:type (Dict
:key_type (Integer
:kind 4
)
:value_type (Real
:kind 4
)
)
)
:overloaded nil
:realloc_lhs false
:move_allocation false
)
(Assignment
:target (Var
:v (SymbolRef 1 "i")
)
:value (DictLen
:arg (Var
:v (SymbolRef 1 "d")
)
:type (Integer
:kind 4
)
:value nil
)
:overloaded nil
:realloc_lhs false
:move_allocation false
)
(Assignment
:target (Var
:v (SymbolRef 1 "x")
)
:value (DictItem
:a (Var
:v (SymbolRef 1 "d")
)
:key (IntegerConstant
:n 1
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:default (RealConstant
:r 0.0
:type (Real
:kind 4
)
)
:type (Real
:kind 4
)
:value nil
)
:overloaded nil
:realloc_lhs false
:move_allocation false
)
(Assignment
:target (Var
:v (SymbolRef 1 "x")
)
:value (DictPop
:a (Var
:v (SymbolRef 1 "d")
)
:key (IntegerConstant
:n 1
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:type (Real
:kind 4
)
:value nil
)
:overloaded nil
:realloc_lhs false
:move_allocation false
)
(Assignment
:target (Var
:v (SymbolRef 1 "p")
)
:value (DictContains
:left (Var
:v (SymbolRef 1 "d")
)
:right (IntegerConstant
:n 1
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:type (Logical
:kind 4
)
:value nil
)
:overloaded nil
:realloc_lhs false
:move_allocation false
)
(DictInsert
:a (Var
:v (SymbolRef 1 "d")
)
:key (IntegerConstant
:n 2
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:value (RealConstant
:r 2.5
:type (Real
:kind 4
)
)
)
(DictClear
:a (Var
:v (SymbolRef 1 "d")
)
)
]
)
}
)
:items []
)