Module: RplLang::Words::Program

Includes:
Types
Included in:
Rpl
Defined in:
lib/rpl/words/program.rb

Instance Method Summary collapse

Methods included from Types

new_object

Instance Method Details

#populate_dictionaryObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rpl/words/program.rb', line 8

def populate_dictionary
  super

  @dictionary.add_word( ['eval'],
                        'Program',
                        '( a -- … ) interpret',
                        proc do
                          args = stack_extract( [:any] )

                          if [RplList, RplNumeric, RplBoolean].include?( args[0].class )
                            @stack << args[0] # these types evaluate to themselves
                          else
                            run( args[0].value.to_s )
                          end
                        end )
end