Do programs written in a strict superset of a language count as a polyglot?

StackOverflow https://stackoverflow.com/questions/4555118

  •  13-10-2019
  •  | 
  •  

문제

First of all, this is the definition of a polyglot:

In the context of computing, a polyglot is a computer program or script written in a valid form of multiple programming languages, which performs the same operations or output independently of the programming language used to compile or interpret it.

But here is the question: If I have a program like this:

#include <stdio.h>

int main() {
  puts("Hello, world!");
  return 0;
}

This is C. As Objective-C (a thin OO-layer on top of C) is a strict superset of C, this could also be Objective-C with the same output, making it a polyglot.

But do strict supersets count when it comes to polyglots (making every single C program a polyglot)?

도움이 되었습니까?

해결책

Strictly speaking, yes that's a polyglot in C and Objective-C. But it won't impress anyone.

Polyglots are more interesting when they work on very different languages. If you can get it working in Python, Brainfuck, Perl and Befunge too it will be slightly more impressive.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top