Replies: 6 comments 3 replies
-
I think this would be a favorable change, at least from a consistency standpoint. |
Beta Was this translation helpful? Give feedback.
-
@ptosco I share the same opinion as @adam-of-barot , it's a good idea (although it will be a painful change hehe) |
Beta Was this translation helpful? Give feedback.
-
@atfera @RamziWeslati please vote on this I know you've been working hard on https://github.com/iktos/molecule-representation |
Beta Was this translation helpful? Give feedback.
-
@Phil-DS any thoughts on this? |
Beta Was this translation helpful? Give feedback.
-
@Oloren-AI , thoughts ? |
Beta Was this translation helpful? Give feedback.
-
I do agree with the change to get_mol, returning null on a bad generation. Cleaner code for bad generations, and is a bit more logical to follow. On a separate point from an Angular point of view, being able to compare to null vs calling the is_valid function in a template is more performant than without, due to how Angular checks for changes. |
Beta Was this translation helpful? Give feedback.
-
Intended audience for this poll
JavaScript developers actively using RDKit MinimalLib (
rdkit-js
).I am tagging a few that I know of here, but there are certainly more:
@MichelML @adam-of-barot @StLeonidas @MariaDolotova @greglandrum
The problem
Currently,
JSMol::get_mol()
always returns aJSMol
object to JavaScript, even when it actually failed generating a molecule from input (i.e, whenMinimalLib::mol_from_input()
returnednullptr
):https://github.com/rdkit/rdkit/blob/f1d8b06fa10180bc0de88b46089b15c093bcee46/Code/MinimalLib/minilib.cpp#L729
In such cases, the
JSMol
object will simply wrap anull
pointer.Therefore, currently JavaScript developers need to check that the
JSMol
object is valid by calling itsis_valid()
method before attempting to do anything with it.Even if the
JSMol
object is invalid, itsdelete()
method must still be called from JavaScript to avoid leaking memory.The proposal
To me, the above seems unnecessary overhead.
My proposal is to have
JSMol::get_mol()
returnnull
to JavaScript upon failure, and deprecate theis_valid()
method.Thus, JavaScript developers will only need to check for the
get_mol()
return value to not benull
before using the molecule (which most likely already do anyway), and they would not need to call itsis_valid()
method anymore.Additionally, they would not need to bother deleting invalid
JSMol
objects as there would be no more invalidJSMol
objects, sinceget_mol()
returnsnull
when it fails to generate a molecule.Initially the
is_valid()
method would be deprecated and would always returntrue
.In a future release the
is_valid()
method would be removed.Please note that the above is a breaking change
If the above proposal is accepted, existing code that currently calls
is_valid()
without previously checking that the returned molecule is notnull
will fail with8 votes ·
Beta Was this translation helpful? Give feedback.
All reactions