Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the exact meaning of anachronism in coding(C++)?

I am using visual studio 2017. In C++, I tried to assign a pointer to 'this' pointer. It showed compiler error as "assignment to 'this' (anachronism)". Anachronism means adding something into the period it can't exist like roman emperor checks computer. So is the compiler warning also like this. Or is there any specific meaning in coding for the word "anachronism"?.

like image 949
prabhakaran Avatar asked Dec 04 '22 18:12

prabhakaran


1 Answers

A good while ago, this pointer could be assigned values. I met such assignments in the code of the Cfront compiler. I wrote about it in this note: Celebrating the 30-th anniversary of the first C++ compiler: let's find the bugs in it. Examples:

expr.expr(TOK ba, Pexpr a, Pexpr b)
{
  register Pexpr p;

  if (this) goto ret;
  ....
  this = p;
  ....
}

inline toknode.~toknode()
{
  next = free_toks;
  free_toks = this;
  this = 0;
}
like image 57
AndreyKarpov Avatar answered Dec 22 '22 00:12

AndreyKarpov