Ruby: include/ruby/internal/scan_args.h File Reference

Ruby 3.4.9p82 (2026-03-11 revision 76cca827ab52ab1d346a728f068d5b8da3e2952b)

Macros | Functions
scan_args.h File Reference

Compile-time static implementation of rb_scan_args(). More...

`#include "ruby/assert.h"`
`#include "ruby/internal/attr/diagnose_if.h"`
`#include "ruby/internal/attr/error.h"`
`#include "ruby/internal/attr/forceinline.h"`
`#include "ruby/internal/attr/nonnull.h"`
`#include "ruby/internal/attr/noreturn.h"`
`#include "ruby/internal/config.h"`
`#include "ruby/internal/dllexport.h"`
`#include "ruby/internal/has/attribute.h"`
`#include "ruby/internal/intern/array.h"`
`#include "ruby/internal/intern/error.h"`
`#include "ruby/internal/intern/hash.h"`
`#include "ruby/internal/intern/proc.h"`
`#include "ruby/internal/iterator.h"`
`#include "ruby/internal/static_assert.h"`
`#include "ruby/internal/stdbool.h"`
`#include "ruby/internal/value.h"`

Go to the source code of this file.

## Macros
#define | HAVE_RB_SCAN_ARGS_OPTIONAL_HASH 1
Possible values that you should pass to rb_scan_args_kw().
#define | RB_SCAN_ARGS_PASS_CALLED_KEYWORDS 0
| Same behaviour as rb_scan_args().
#define | RB_SCAN_ARGS_KEYWORDS 1
| The final argument should be a hash treated as keywords.
#define | RB_SCAN_ARGS_LAST_HASH_KEYWORDS 3
| Treat a final argument as keywords if it is a hash, and not as keywords otherwise.
Possible values that you should pass to rb_funcallv_kw().
#define | RB_NO_KEYWORDS 0
| Do not pass keywords.
#define | RB_PASS_KEYWORDS 1
| Pass keywords, final argument should be a hash of keywords.
#define | RB_PASS_CALLED_KEYWORDS !!rb_keyword_given_p()
| Pass keywords if current method is called with keywords, useful for argument delegation.

## Functions
int | rb_scan_args (int argc, const VALUE *argv, const char *fmt,...)
| Retrieves argument from argc and argv to given VALUE references according to the format string.
int | rb_scan_args_kw (int kw_splat, int argc, const VALUE *argv, const char *fmt,...)
| Identical to rb_scan_args(), except it also accepts kw_splat.

## Detailed Description

Compile-time static implementation of rb_scan_args().

Author
  Ruby developers ruby-.nosp@m.core.nosp@m.@ruby.nosp@m.-lan.nosp@m.g.org

Copyright
  This file is a part of the programming language Ruby. Permission is hereby granted, to either redistribute and/or modify this file, provided that the conditions mentioned in the file COPYING are met. Consult the file for details.

Warning
  Symbols prefixed with either RBIMPL or rbimpl are implementation details. Don't take them as canon. They could rapidly appear then vanish. The name (path) of this header file is also an implementation detail. Do not expect it to persist at the place it is now. Developers are free to move it anywhere anytime at will.

Note
  To ruby-core: remember that this header can be possibly recursively included from extension libraries written in C++. Do not expect for instance __VA_ARGS__ is always available. We assume C99 for ruby itself but we don't assume languages of extension libraries. They could be written in C++98.

This is a beast. It statically analyses the argument spec string, and expands the assignment of variables into dedicated codes.

Definition in file scan_args.h.

## Macro Definition Documentation

## ◆ HAVE_RB_SCAN_ARGS_OPTIONAL_HASH

#define HAVE_RB_SCAN_ARGS_OPTIONAL_HASH 1

Deprecated
  This macro once was a thing in the old days, but makes no sense any longer today. Exists here for backwards compatibility only. You can safely forget about it.

Definition at line 89 of file scan_args.h.

## ◆ RB_NO_KEYWORDS

#define RB_NO_KEYWORDS 0

Do not pass keywords.

Definition at line 69 of file scan_args.h.

Referenced by rb_block_call(), rb_call_super(), rb_check_funcall(), rb_class_new_instance(), rb_fiber_resume(), rb_fiber_transfer(), rb_fiber_yield(), rb_method_call_with_block(), rb_mod_module_eval(), rb_mod_module_exec(), rb_obj_call_init(), rb_obj_instance_eval(), rb_obj_instance_exec(), rb_proc_call(), and rb_proc_call_with_block().

## ◆ RB_PASS_CALLED_KEYWORDS

#define RB_PASS_CALLED_KEYWORDS !!rb_keyword_given_p()

Pass keywords if current method is called with keywords, useful for argument delegation.

Definition at line 78 of file scan_args.h.

Referenced by rb_class_new_instance_pass_kw().

## ◆ RB_PASS_KEYWORDS

#define RB_PASS_KEYWORDS 1

Pass keywords, final argument should be a hash of keywords.

Definition at line 72 of file scan_args.h.

## ◆ RB_SCAN_ARGS_KEYWORDS

#define RB_SCAN_ARGS_KEYWORDS 1

The final argument should be a hash treated as keywords.

Definition at line 53 of file scan_args.h.

## ◆ RB_SCAN_ARGS_LAST_HASH_KEYWORDS

#define RB_SCAN_ARGS_LAST_HASH_KEYWORDS 3

Treat a final argument as keywords if it is a hash, and not as keywords otherwise.

Definition at line 59 of file scan_args.h.

## ◆ RB_SCAN_ARGS_PASS_CALLED_KEYWORDS

#define RB_SCAN_ARGS_PASS_CALLED_KEYWORDS 0

Same behaviour as rb_scan_args().

Definition at line 50 of file scan_args.h.

Referenced by rb_scan_args().