This repository has been archived on 2026-05-19. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
foreign-thon-old/docs/postfix-syntax.md

1.1 KiB

Postfix Syntax

Some languages (like Tamil) are grammatically SOV — the condition comes before the keyword, not after. ForeignThon supports this with the @@ operator.

How it works

# Standard prefix (works in every language)
si x > 0:
    imprimir(x)

# Postfix with @@
x > 0 @@si:
    imprimir(x)

Both produce identical Python: if x > 0:. The @@ means "take whatever is to my left, put the keyword first".

Rules

  • @@ only rewrites the line it appears on — nothing else changes
  • Indentation rules are identical to normal Python
  • Prefix and postfix can be mixed freely in the same file
  • Works for any keyword in any language pack

Examples

# if / else
x > 0 @@si:
    imprimir(x)
sino:
    pasar

# while
contador < 10 @@mientras:
    contador += 1

# inside a function — indentation unchanged
definir comprobar(x):
    x > 0 @@si:
        imprimir("positivo")
    sino:
        imprimir("negativo")

Why @@

@@ is not valid Python syntax so it never conflicts with existing code. Single @ is used for decorators and matrix multiplication, so it was ruled out.