Skip to content

Redshift: no current module name in FQN by default? - #590

Open
paugier wants to merge 1 commit into
spylang:mainfrom
paugier:idea-rs-simpler-fqn
Open

paugier wants to merge 1 commit into
spylang:mainfrom
paugier:idea-rs-simpler-fqn

Conversation

@paugier

@paugier paugier commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Related to #474

It seems to me that the current module name should not be displayed in FQN by default.

For real world code (longer than simple examples), it considerably simplify the output which becomes much more readable.

Of course, the full FQN can be obtained with --full-fqn.

For example, applied to one of the example:

# before
$ spy rs examples/4_advanced/myarray.spy | wc -m
14156
# with this PR
$ spy rs examples/4_advanced/myarray.spy | wc -m
13211

And for a typical function:

# before
def `myarray::Array1d[i32]::__ne__`(a: `myarray::Array1d[i32]`, b: `myarray::Array1d[i32]`) -> bool:
    return `operator::bool_not`(`unsafe::gc_ptr[myarray::ArrayData[i32]]::__eq__`(`myarray::Array1d[i32]::__get___ll____`(a), `myarray::Array1d[i32]::__get___ll____`(b)))
 
# with this PR
def `Array1d[i32]::__ne__`(a: `Array1d[i32]`, b: `Array1d[i32]`) -> bool:
    return `operator::bool_not`(`unsafe::gc_ptr[ArrayData[i32]]::__eq__`(`Array1d[i32]::__get___ll____`(a), `Array1d[i32]::__get___ll____`(b)))

@paugier paugier changed the title redshift no current module name in FQN by default Redshift: no current module name in FQN by default Jun 20, 2026
@paugier

paugier commented Jun 20, 2026

Copy link
Copy Markdown
Contributor Author

Alternatively, this behavior could be a new triggered by a new redshift option?

@paugier paugier changed the title Redshift: no current module name in FQN by default Redshift: no current module name in FQN by default? Jun 20, 2026
@paugier
paugier force-pushed the idea-rs-simpler-fqn branch from 8482e36 to 9abfd18 Compare June 20, 2026 21:31
@antocuni

antocuni commented Jun 20, 2026

Copy link
Copy Markdown
Member

+1 for the goal, but I'm not sure this is the right approach: we already have FQN.human_name, let's try to make it even more human.

I propose the following:

  • FQN.human_name takes an optional parent argument, which is another FQN, and strips the parent from the output;
  • the spy backend keeps track of the current parent, and pass it to human_name.

Two things which I like of this approach are:

  1. we can strip the parent "properly", without having to resort to fragile regexps.
  2. it works for any kind of nesting, not only for module names

One open question: how do we format a stripped FQN? Imagine this:

# mod.spy
@struct
class T:
    def bar(self) -> None:
        pass

One option is to just strip the parent and be happy; another is to use some kind of "relative to here" marker:

@struct
class `./T`:
    def `./bar`(self) -> None:
        pass

Just to be clear, I don't like the ./ syntax, but it's to show what I mean.
The problem is that I cannot find any syntax which I like. Some proposals:

  • ./T
  • .::T
  • ::T
  • .T
  • ^T

Of these, I think I like .T a bit more than the others.

@paugier
paugier force-pushed the idea-rs-simpler-fqn branch from ced95b4 to 8095b9e Compare September 12, 2026 19:30
@paugier

paugier commented Sep 12, 2026

Copy link
Copy Markdown
Contributor Author

I changed the implementation with _human_render(self, parent).

I didn't change yet class T: in

class `.T`:

I'm not sure that it is so useful. What does it add to have `.T` instead of T? Isn't it implicit that T is defined in the current module? Simple names (without ::) are either defined in the current module or builtins. It's simple and clear. And we have --full-fqn when needed.

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.

2 participants