Knowledge

Dispatch table

Source 📝

515: 500: 28: 406: 44: 36: 421: 462: 425: 409: 400: 60: 8: 485: 496: 64: 20: 413: 32: 509: 490: 441: 40: 16:
Computer code structure with a table of pointers to functions or similar
432:, and every call to a virtual method is dispatched through the vtable. 72:# Define the table using one anonymous code-ref and one named code-ref 417: 216:
Following is a demo of implementing dispatch table in JavaScript:
420:
will automatically create a dispatch table for each object of a
39:. Use of such a table is a common technique when implementing 55:
The following shows one way to implement a dispatch table in
56: 424:containing virtual methods. This table is called a 147:# Fetch the code ref from the table, and invoke it 507: 211: 63:to store references to code (also known as 394: 204:will produce "hello", and running it as 508: 50: 460: 13: 14: 527: 463:"Function Dispatch Tables in C" 495:. Boston, MA: Addison-Wesley. 454: 192:"unknown argument\n" 1: 516:Method (computer programming) 493:: The Open Source Perspective 447: 200:Running this Perl program as 7: 435: 45:object-oriented programming 10: 532: 398: 212:JavaScript implementation 218: 208:will produce "goodbye". 69: 410:programming languages 395:Virtual method tables 138:"goodbye\n" 426:virtual method table 401:Virtual method table 380:"default" 102:"hello\n" 51:Perl implementation 486:Diomidis Spinellis 467:alicegoldfuss.com 461:Goldfuss, Alice. 65:function pointers 523: 478: 477: 475: 473: 458: 390: 387: 384: 381: 378: 375: 372: 369: 366: 363: 360: 357: 354: 351: 348: 345: 342: 339: 336: 333: 330: 327: 324: 321: 318: 315: 312: 309: 306: 303: 300: 297: 294: 291: 288: 285: 282: 279: 276: 275:doThisOtherThing 273: 270: 267: 264: 261: 258: 255: 252: 249: 246: 243: 240: 237: 234: 231: 228: 225: 222: 207: 203: 196: 193: 190: 187: 184: 181: 178: 175: 172: 169: 166: 163: 160: 157: 154: 151: 148: 145: 142: 139: 136: 133: 130: 127: 124: 121: 118: 115: 112: 109: 106: 103: 100: 97: 94: 91: 88: 85: 82: 79: 76: 73: 35:to functions or 33:memory addresses 21:computer science 531: 530: 526: 525: 524: 522: 521: 520: 506: 505: 482: 481: 471: 469: 459: 455: 450: 438: 414:virtual methods 407:object-oriented 403: 397: 392: 391: 388: 385: 382: 379: 376: 373: 370: 367: 364: 361: 358: 355: 352: 349: 346: 343: 340: 337: 334: 331: 328: 325: 322: 319: 316: 313: 310: 307: 304: 301: 298: 295: 292: 289: 286: 283: 280: 277: 274: 271: 268: 265: 262: 259: 256: 253: 250: 247: 244: 241: 238: 235: 232: 229: 226: 223: 220: 214: 205: 201: 198: 197: 194: 191: 188: 185: 182: 179: 176: 173: 170: 167: 164: 161: 158: 155: 152: 149: 146: 143: 140: 137: 134: 131: 128: 125: 122: 119: 116: 113: 110: 107: 104: 101: 98: 95: 92: 89: 86: 83: 80: 77: 74: 71: 53: 17: 12: 11: 5: 529: 519: 518: 504: 503: 480: 479: 452: 451: 449: 446: 445: 444: 437: 434: 399:Main article: 396: 393: 359:hasOwnProperty 311:/* behavior */ 290:/* behavior */ 269:/* behavior */ 248:/* behavior */ 219: 213: 210: 111:"-g" 87:"-h" 70: 52: 49: 27:is a table of 25:dispatch table 15: 9: 6: 4: 3: 2: 528: 517: 514: 513: 511: 502: 501:0-201-79940-5 498: 494: 492: 487: 484: 483: 468: 464: 457: 453: 443: 440: 439: 433: 431: 427: 423: 419: 415: 412:that support 411: 408: 402: 383:thingsWeCanDo 353:thingsWeCanDo 224:thingsWeCanDo 217: 209: 206:perl greet -g 202:perl greet -h 68: 66: 62: 58: 48: 46: 42: 38: 34: 30: 26: 22: 491:Code Reading 489: 470:. Retrieved 466: 456: 442:Branch table 429: 404: 215: 199: 54: 41:late binding 24: 18: 323:doSomething 254:doThatThing 233:doThisThing 129:say_goodbye 120:say_goodbye 472:23 January 448:References 159:$ dispatch 59:, using a 347:thingToDo 78:%dispatch 510:Category 488:(2003). 436:See also 418:compiler 329:function 302:function 281:function 260:function 239:function 29:pointers 296:default 37:methods 499:  430:vtable 416:, the 374:doWhat 365:doWhat 335:doWhat 165:$ ARGV 135:return 117:\& 99:return 422:class 183:-> 180:$ sub 174:$ sub 171:print 153:$ sub 114:=> 90:=> 497:ISBN 474:2021 61:hash 57:Perl 23:, a 428:or 405:In 386:(); 344:var 320:var 221:var 126:sub 93:sub 67:). 43:in 31:or 19:In 512:: 465:. 317:}; 305:() 293:}, 284:() 272:}, 263:() 251:}, 242:() 186:() 168:}; 150:my 123:); 108:}, 75:my 47:. 476:. 389:} 377:: 371:? 368:) 362:( 356:. 350:= 341:{ 338:) 332:( 326:= 314:} 308:{ 299:: 287:{ 278:: 266:{ 257:: 245:{ 236:: 230:{ 227:= 195:; 189:: 177:? 162:{ 156:= 144:} 141:; 132:{ 105:; 96:{ 84:( 81:=

Index

computer science
pointers
memory addresses
methods
late binding
object-oriented programming
Perl
hash
function pointers
Virtual method table
object-oriented
programming languages
virtual methods
compiler
class
virtual method table
Branch table
"Function Dispatch Tables in C"
Diomidis Spinellis
Code Reading
ISBN
0-201-79940-5
Category
Method (computer programming)

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.