54

I understand the this (or self or Me) is used to refer to the current object, and that it is a feature of object-oriented programming languages. The earliest language I could find which has such a concept was Smalltalk, which uses self but was wondering where and when (which programming language) the concept was first implemented?

huijing
  • 651
  • 1
  • 5
  • 7

1 Answers1

61

Simula 67 is generally considered the first object-oriented language and predates Smalltalk by a number of years.

It also used the this keyword for the same concept, which can be seen in this book chapter extract:

  class Linker;
  begin
     ref(Linker) Next, Sex, Employment;
     text ID;

     procedure Add_to_List(LHead); name LHead; ref(Linker) LHead;
     begin
        Next :- LHead;
        LHead :- this Linker
     end..of..Add..to..List;

     procedure Onto_Lists(Gender,Occupation);
         name Gender,Occupation;
         ref(Linker) Gender,Occupation;
     begin
        Sex :- Gender;
        Employment :- Occupation;
        Gender :- Occupation :- this Linker
     end..of..Onto..Lists;

     InImage;
     ID :- Copy(SysIn.Image);
     InImage;
  end--of--Linker;
  • 4
    Interesting! What's up with those end.. and end-- bits? Do they constitute part of the syntax? – jogloran Mar 07 '20 at 21:31
  • 5
    @jogloran: The Vim syntax-highlighting rules for Simula says: "Text between the keyword 'end' and either a semicolon or one of the keywords 'end', 'else', 'when' or 'otherwise' is also a comment." [link] That's obviously not authoritative -- it just means that Vim would color the ..of..Onto..Lists and --of--Linker and so on as comments -- but judging from the examples in the book chapter and elsewhere, I think that they are indeed optional comments (albeit not wholly freeform). – ruakh Mar 07 '20 at 22:22
  • 4
    FWIW, a book I have here called "Introduction to Simula 67" gives the same rule as the Vim rule set mentioned by @ruakh, i.e. comments can directly follow the keyword END but may not contain any of the following: ;, END, WHEN, OTHERWISE, ELSE. Comments in the block body need to start with the keyword COMMENT. – njuffa Mar 08 '20 at 00:04
  • 1
    @njuffa You are correct --- Simula67 used the old Algol60 comment style. I haven't used Simula67 since the 1970s though. It was in some ways more advanced than C++ which was an attempt to implement as much of Simula67 as possible using C. But Simula67 had coroutines which did not make it into C++. – Martin Ellison Apr 02 '20 at 07:44
  • 1
    Nitpick: Smalltalk-80 was the first generally available version but Smalltalk-71 was the first iteration: http://worrydream.com/EarlyHistoryOfSmalltalk/ – user3810626 Apr 02 '20 at 23:50
  • @user3810626 Excellent reference. Thanks for the comment – Brian Tompsett - 汤莱恩 Apr 03 '20 at 07:38