Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

COBOL has a worse construct than this.

ALTER LABEL1 TO PROCEED TO LABEL2

This will cause any gotos to LABEL1 to be redirected to LABEL2.

This is worse than older Fortran's arithmetic IF[0].

[0] https://en.wikipedia.org/wiki/Arithmetic_IF



That construct is very useful when the memory is measured in few kilowords and the call stack is tiny.

Cobol was first used in computers that are equivalent to $1.5 PIC18 microcontrollers https://www.microchip.com/paramchartsearch/chart.aspx?branch...


yeah, it's funny. This would be like car people (or pick any other group) in forums, pointing to some super popular car made 50 years ago and then making fun/light of all the crazy stuff the best engineers at the time felt was necessary.


Arithmetic IF and COBOL's ALTER statement were reasonable solutions at the time but that doesn't make them any easier to use or understand in the present.


That arithmetic IF sounds really useful for the kind of numerical applications typically written in Fortran. Isn't it only bad because every other language uses IF as a boolean conditional?


Arithmetic IF directly matches a hardware instruction on the IBM 704.

This was the first computer with a Fortran compiler.

IF (VALUE) 10, 20, 30

The three arguments after the value are labels that the program jumps to.

The equivalent of this line in C is something like this:

  if (value < 0)
  {
    goto 10;
  }
  else if (value == 0)
  {
    goto 20;
  }
  else
  {
    goto 30;
  }
Fortran 77 added logical IFs that work like most other programing languages.


You can do that (or worse) in C too.

#define LABEL1 LABEL2

Is there any language that can be worse than a macro and #ifdef-ridden C? I'm only half joking.


Your C #define is done at compile time. This Cobol's alter example [1] seem to do so at runtime. Thus labels can be considered modifiable points. Actually, it's kinda interesting... does it support chains? Alter A->B and B->C, does GoTo A call C? If i now alter X->A then A->D and GoTo X, where do you end up? C? D? Hope you can at least undo that with something like alter A->A. Actually, I probably don't even want to know. Hope using it gives a big warning in whatever tools Cobal devs use.

[1] https://riptutorial.com/cobol/example/19820/a-contrived-exam...


#define's are a compile time construct though. I think the parent is describing a statement that alters the runtime location of a label.


I am much happier knowing this thank you


Happy as in happy to never need to touch something like that


Yes it just fills me with appreciation for what I've taken for granted

(although working in javascript of course any function can get redefined at any time so some things never change)


Metaprogramming. Nice.


It's self-modifying code, which is not the same thing as metaprogramming, which utilizes unexpanded expressions (often macros) which then get expanded in the final evaluation.


The term meta programming in languages like Ruby and many others tends to be taken to include the language ability to dynamically alias (or create) methods at runtime. I don't think I can remember having seen it used to mean something as restrictive as you suggest



But COMEFROM is a joke. Dynamic scope for goto labels is apparently real.


Looks good to me!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: