[798] in Coldmud discussion meeting

root meeting help first previous next next in chain last in chain last

Consider: native methods question

daemon@ATHENA.MIT.EDU (Fri Sep 8 04:48:15 1995 )

Date: Fri, 8 Sep 1995 02:42:14 -0600
From: 869683 Gillespie Brandon James <brandon@clarkston.declab.usu.edu>
To: coldstuff@MIT.EDU

Native methods are simply functions bound on an object in the same means
as a method, and which do not exist in the opcode table.

I'm considering two implementations:

  #1: Add them to the methods list, hooking into the native code rather than
      the pcode.  The disadvantage of this lies in it can be awkward.
  #2: adding a new operator which is a native method operator, for now let
      us pretend this is '&', so to call a native method you would execute
      (from the object which has them hashed) it with:


      This would give you more configurability, in that you could more
      easilly create wrappers.  For instance, consider the string functions,
      if you wanted to add 'fill', you would:

          arg length;

          return &pad("", length);

      Or of even more consideration, let us say that the function 'format'
      exists (as it does in 0.1-6), but rather than submitting the first
      argument as the format (string) and the second argument as a list,
      you want to submit the second arguments plus any subsequent number
      of arguments.  You could do this with:

          public format: native
              arg format, [args];

              return &format(format, args);

I dont know which one I would prefer.  I probably would _not_ use & as an
operator, perhaps have an do_func() or something call...