Ticket #1895 (closed deprecation: invalid)

Opened 11 years ago

Last modified 10 years ago

[DEPRECATED] difference between :load and :init Sub flags

Reported by: plobsing Owned by: whiteknight
Priority: normal Milestone:
Component: imcc Version: master
Severity: medium Keywords: IMCC, Packfiles
Cc: Language:
Patch status: Platform: all

Description

Depending on whether PIR is being run or loaded, :init or :load flagged subs get invoked.

This distinction is meaningless and results in many subs being flagged :init :load, as well as unecessary complexity in the implementaiton.

:load will take on the role of both behaviours. :init will become a no-op for a deprecation cycle.

Change History

in reply to: ↑ description   Changed 11 years ago by doughera

Replying to plobsing:

Depending on whether PIR is being run or loaded, :init or :load flagged subs get invoked. This distinction is meaningless and results in many subs being flagged :init :load, as well as unecessary complexity in the implementaiton.

Is it truly meaningless? I thought Rakudo made use of this distinction.

in reply to: ↑ description   Changed 11 years ago by pmichaud

This distinction is meaningless and results in many subs being flagged :init :load, as well as unecessary complexity in the implementaiton.

Completely wrong about the distinction being "unnecessary". The important distinction is that subs marked :init are invoked when the module (.pir or .pbc) is run as the main program from the Parrot command line, while subs marked :load are invoked when loaded from a running Parrot program (e.g., via load_bytecode) but not when invoked from the command line.

Rakudo (and most other PCT-based tools) absolutely make use of this distinction. There are some initializations that should only take place if a module is being invoked from the command line, and there are others that should only take place if a module is being loaded from a running Parrot program. Indeed, at one time we only had a :load flag, and :init was introduced because :load couldn't handle all of the important distinctions on its own.

Please don't take a horrible step backwards on this point. If anything, Parrot needs *more* distinctions between the different times of initializations that can occur, not less.

Pm

  Changed 11 years ago by whiteknight

  • owner set to whiteknight
  • keywords IMCC, Packfiles added
  • component changed from none to imcc

Patrick, I would really like to hear more about how Rakudo uses the :load and :init flags currently. We're starting to plan some significant changes/cleanups/improvements (especially performance improvements) in the compilers and packfiles code in the coming months. I want to make sure that we can make these changes without taking away what our users need, but I also want to make sure that we are providing the right tools and the right interfaces.

I strongly suspect that the :load and :init flags we have now are not the right solution to your needs in the long term, but I want to make sure I understand your use-cases.

  Changed 11 years ago by pmichaud

Comment #3 on TT #1932 explains why Rakudo and NQP need to have a flag (currently :load) that distinguishes load_bytecode from other invocation/loading mechanisms.

Pm

  Changed 11 years ago by whiteknight

  • status changed from new to assigned
  • platform set to all
  • version changed from 2.10.0 to master
  • milestone 2.11 deleted

I think we are not going to pursue this proposal, and are instead talking about alternative ways to clean up and improve the flagging of Subs for various purposes. I will leave this ticket open for a few days for comments, but I think we are going to reject it and focus on other improvements.

follow-up: ↓ 7   Changed 11 years ago by whiteknight

In the whiteknight/imcc_tag branch I have implemented a new PIR syntax which could potentially be used to completely replace :load, :init, and some other pragmata as well. It looks like this:

.sub 'foo' :tags("load", "init", "baz", "etc")
.end

You can provide any arbitrary string tags to a Sub. Then, if you have a PackfileView PMC, you can get lists of subs by tag:

$P0 = load_bytecode "foo.pbc"
$P1 = $P0.'subs_by_flag'("load")

Notice that the load_bytecode_p_s opcode doesn't do any execution of Subs automatically, unlike load_bytecode_s. This gives the user the ability to tag subs however they want, get them whenever, and execute them at any time. I think we are going to close this ticket, work on the new :tag syntax, and eventually deprecate :load and :init flags in favor of this new, more flexible alternative.

in reply to: ↑ 6   Changed 10 years ago by jkeenan

Replying to whiteknight:

In the whiteknight/imcc_tag branch I have implemented a new PIR syntax

whiteknight,

I believe the imcc_tag branch has been merged. If so, can you give us an update on the status of this ticket? (TT #1895 appears to depend on this ticket as well.)

Thank you very much.

kid51

  Changed 10 years ago by whiteknight

  • status changed from assigned to closed
  • resolution set to invalid

  Changed 10 years ago by whiteknight

We've decided not to pursue this, and are looking at the :tag syntax instead.

Note: See TracTickets for help on using tickets.