Pointers is an actively used design pattern created in 1964.

55Years Old
  • Pointers ranks in the top 50% of entities I track
  • the Pointers wikipedia page
  • Pointers first appeared in 1964
  • I have 21 facts about Pointers. what would you like to know? email me and let me know how I can help.

Languages without Pointers include javascript

Languages with Pointers include ada, blitzmax, c, cobol, csharp, d, eiffel, fortran-90, freebasic, go, pl-i

Example from c:

int *ptr;

Example from csharp:

// Pointers supported only under certain conditions.
// Get 16 bytes of memory from the process's unmanaged memory
IntPtr pointer = System.Runtime.InteropServices.Marshal.AllocHGlobal(16);

Example from fortran-90:

type real_list_t
  real :: sample_data(100)
  type (real_list_t), pointer :: next => null ()
end type

type (real_list_t), target :: my_real_list
type (real_list_t), pointer :: real_list_temp

real_list_temp => my_real_list
  read (1,iostat=ioerr) real_list_temp%sample_data
  if (ioerr /= 0) exit
  allocate (real_list_temp%next)
  real_list_temp => real_list_temp%next
end do

Example from go:

package main

import "fmt"

func main() {
  i, j := 42, 2701

  p := &i         // point to i
  fmt.Println(*p) // read i through the pointer
  *p = 21         // set i through the pointer
  fmt.Println(i)  // see the new value of i

  p = &j         // point to j
  *p = *p / 37   // divide j through the pointer
  fmt.Println(j) // see the new value of j

Last updated July 8th, 2019