Skip to content

Conversation

@igrvlhlb
Copy link
Contributor

This pull request adds support for extracting and displaying type declarations for Pallene modules. The main changes introduce a new .ptf output file containing type information for exported names, and a new --print-types command-line flag. Supporting code and test updates ensure .ptf files are generated propperly.

Type extraction and output support:

  • Added a new module src/pallene/type_extractor.lua that generates type declarations for exported names in Pallene modules.
  • Updated src/pallene/driver.lua to support compiling .pln files to .ptf files and to invoke type extraction when building shared objects. [1] [2] [3] [4] [5]

Command-line and test integration:

  • Added a --print-types flag to the Pallene compiler CLI (src/pallene/pallenec.lua), allowing users to print type information to stdout. [1] [2] [3] [4]
  • Updated tests to check for .ptf file creation and clean up .ptf files after test runs. [1] [2] [3] [4] [5]

@hugomg
Copy link
Member

hugomg commented Nov 18, 2025

Qual é a diferença entre aquelas funções lá do type_extractor e coisas como a types.tostring do types.T?

@igrvlhlb
Copy link
Contributor Author

Qual é a diferença entre aquelas funções lá do type_extractor e coisas como a types.tostring do types.T?

Há algumas:

  1. ao passar uma função types.tostring() a saída é function <paramtypes> -> <rettypes>; no type_extractor nós geramos a representação ( <paramtypes> ) -> <rettypes> (parênteses opcionais a depender da quantidade de parâmetros)
  2. os campos das tables não são ordenados para impressão no type_extractor
  3. em types.tostring(), ao receber um Record, a saída é só seu nome. No type_extractor imprimimos seus nomes de campos e respectivos tipos
  4. Em types.tostring(), ao receber um tipo Alias, fiz com que a saída fosse <nominal> [aka <actual>], enquanto que em type_extractor a saída é o próprio nome do alias.

Em suma, types.tostring() tem uma saída mais expressiva, pensada para mensagens para o usuário, por exemplo, enquanto type_extractor tem uma saída que tenta replicar a sintaxe de declaração de tipos em Pallene.

@hugomg
Copy link
Member

hugomg commented Nov 19, 2025 via email

@igrvlhlb
Copy link
Contributor Author

Ok! Acho que seria uma boa ideia falar disso num comentário no código.

@hugomg feito! Aproveitei e subi a mudança da extensão do arquivo de tipos: .ptf -> .d.pln

@igrvlhlb igrvlhlb merged commit acc56b8 into master Nov 28, 2025
2 checks passed
@igrvlhlb igrvlhlb deleted the emit-types branch November 28, 2025 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants