Skip to content

Conversation

@sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Oct 3, 2025

This helps with readability IMHO since you don't need to do a double negative when considering the #else block.

@sbc100 sbc100 requested review from brendandahl and kripken October 3, 2025 20:14
warn('To build in STANDALONE_WASM mode without a main(), use emcc --no-entry');
}
}
if (!RELOCATABLE) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OTOH, "not relocatable == normal", and it's nice to have the normal path first? Then reading the more complex relocatable one after is easier.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one has annoyed me for a while. Every time I read I feel like have to do mental work for some reason.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the negation here is annoying, how about var ABSOLUTE = !RELOCATABLE or some better name for "simple, absolute-addressed single file with no linking involved" - ?

(Perhaps "linked file", "relocated file", "flat file" - maybe there is a good term?)

That would avoid the negation, and also let us keep having the simple code first in each such if-else.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually in this case I like the if RELOCATABLE.

The code here is part of the undefined symbol handling. Its within a block and its already an error in most cases.

It reads like this:

if (is_undefined) {
   maybe_report_an_error();
   // Here we are continuing with the undefined symbol
   if (RELOCATABLE) {  // AKA dynamic linking
      create_a_dylink_stub();
   } else {
      create_an_abort_stub();
   } 
}

I think this is more logical that the other way around:

if (is_undefined) {
   maybe_report_an_error();
   // Here we are continuing with the undefined symbol
   if (!RELOCATABLE) {
      create_an_abort_stub();
   } else {
      create_a_dylink_stub();
   } 
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough, I can live with this one. Reading the others again now.

// regarding this function, marking ot a variadic function that can take in anything and return anything.
// (not useful to warn/error multiple times)
LibraryManager.library[symbol + '__docs'] = '/** @type {function(...*):?} */';
isStub = true;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed the isStub = true; is repeated in both condition here too

@sbc100 sbc100 force-pushed the positive_conditionals branch from 828c25f to 5977f9e Compare October 3, 2025 20:53
This helps with readability IMHO since you don't need to do a double
negative when considering the `#else` block.
@sbc100 sbc100 force-pushed the positive_conditionals branch from 5977f9e to ba08f70 Compare October 3, 2025 21:30
@sbc100 sbc100 enabled auto-merge (squash) October 3, 2025 22:25
@sbc100
Copy link
Collaborator Author

sbc100 commented Oct 3, 2025

Ok to land?

@sbc100 sbc100 merged commit 9bc3ffa into emscripten-core:main Oct 3, 2025
33 checks passed
@sbc100 sbc100 deleted the positive_conditionals branch October 3, 2025 22:59
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