Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #27799

late binding

From Paul Rubin <no.email@nospam.invalid>
Newsgroups comp.lang.forth
Subject late binding
Date 2014-01-11 01:59 -0800
Organization Nightsong/Fort GNOX
Message-ID <7xr48eg7q1.fsf@ruckus.brouhaha.com> (permalink)

Show all headers | View raw


In this era of avant-garde Forth innovation such as Chuck using circular
stacks and having IF not pop the condition from the stack, I wonder if
anyone has experimented with late binding.  Basically if you say

  : FOO 1 BAR + ;

instead of getting an error message saying BAR is undefined, the
compiler would just make a dictionary entry for BAR, with its CFA
pointing to code that prints an error message.  Only when you try to
actually run FOO, do you get a message saying BAR is undefined.  If you
say

   : FOO 1 BAR + ;
   : BAR 4 ;

then the : BAR finds the existing dictionary entry for BAR and
overwrites the CFA in-place.  Now running FOO prints 5.  You can
redefine BAR:

   : FOO 1 BAR + ;
   : BAR 4 ;

   FOO   5 ok    \ FOO prints 5

   : BAR 8 ;     \ overwrite the same CFA again
   FOO   9 ok    \ FOO now prints 9

It costs an extra memory access depending on implementation, not too
bad.  The advantage is you can now redefine words during debugging,
without having to reload the whole program which usually means
clobbering the program state.  When you redefine a word, all callers
will now call the new word.  Also you no longer have to define each word
before it's used.

I know you can do a version of this with DEFER, but this idea is more
pervasive.

Is this just terrible, from a Forth cultural (or other) standpoint?

Back to comp.lang.forth | Previous | NextNext in thread | Find similar | Unroll thread


Thread

late binding Paul Rubin <no.email@nospam.invalid> - 2014-01-11 01:59 -0800
  Re: late binding Andrew Haley <andrew29@littlepinkcloud.invalid> - 2014-01-11 04:16 -0600
    Re: late binding Paul Rubin <no.email@nospam.invalid> - 2014-01-11 03:06 -0800
      Re: late binding anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2014-01-13 15:31 +0000
  Re: late binding albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-01-11 14:05 +0000
  Re: late binding Ron Aaron <rambamist@gmail.com> - 2014-01-11 17:58 +0200
  Re: late binding "Elizabeth D. Rather" <erather@forth.com> - 2014-01-11 08:55 -1000
    Re: late binding Paul Rubin <no.email@nospam.invalid> - 2014-01-11 11:23 -0800
      Re: late binding "Elizabeth D. Rather" <erather@forth.com> - 2014-01-11 10:37 -1000
  Re: late binding Michael L Gassanenko <m_l_g3@yahoo.com> - 2014-01-13 00:01 -0800
    Re: late binding m.a.m.hendrix@tue.nl - 2014-01-13 04:18 -0800
  Re: late binding Mark Wills <markrobertwills@yahoo.co.uk> - 2014-01-13 00:51 -0800
  Re: late binding Matthias Koch <matthias.koch@hot.uni-hannover.de> - 2014-01-13 14:40 +0100
  Re: late binding anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2014-01-13 14:41 +0000

csiph-web