Debian Codegraph @

inst/FAQ

raw
1
2 proto Package FAQ
3
4 1. What scope do unqualified object references within methods use?
5
6 A proto object is an environment and the defined methods in a proto object have
7 that environment as their parent. Thus unqualified object references
8 within a proto method look first in the method itself and secondly in the
9 proto object in which they are defined. This is referred to as object
10 scope as opposed to lexical scope or dynamic scope. It allows simple
11 situations where delegation is not used to use unqualified names. Thus
12 simple situations remain simple. Also read
13
14 http://hhbio.wasser.tu-dresden.de/projects/proto/prototype_approaches.pdf
15
16 about the fragile base class problem for additional information that
17 relates to this question.
18
19
20 2. Why does obj$meth not return the method, meth?
21
22 obj$meth(x, y) needs to call meth(obj, x, y) so obj$meth needs to
23 return meth with its first argument, obj, already inserted. Since
24 calling a method is the most common operation that operation was made
25 the simplest. To get the method itself use with(obj, meth)
26
27
28 3. How does one debug a method?
29
30 proto will not dynamically redefine methods. This has the advantage
31 that debug can be used. Be sure you are referring to the method itself
32 and not a call to the method:
33
34 with(obj, debug(meth))
35
36 and not
37
38 debug(obj$meth) # wrong!
39
40
41 4. Is multiple inheritance supported?
42
43 No. proto is just a thin layer on top of R environments and R environments
44 provide single inheritance only. Note that:
45
46 http://hhbio.wasser.tu-dresden.de/projects/proto/prototype_approaches.pdf
47
48 discusses some ways of handling situations which would otherwise require
49 multiple inheritance.
50
51
52 5. How does one document proto methods.
53
54 One can use an R .Rd file together with \alias entries.