# adds the keyvalues list to the map (if not map specified created one)
function(map_from_keyvaluelist map)
  if(NOT map)
    map_new()
    ans(map)
  endif()
  set(args ${ARGN})
  while(true)
    list_pop_front(args)
    ans(key)
    list_pop_front(args)
    ans(val)
    if(NOT key)
      break()
    endif()
    map_set("${map}" "${key}" "${val}")
  endwhile()
  return_ref(map)
endfunction()