[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-users] Defining class only if not defined?



On Sun, Dec 22, 2019 at 10:39 AM <marc@xxxxxxxxxxxxxxxxx> wrote:
> Is there a way to write an extension that defines a class only if it
> hasn't been previously defined?
>
> As part of a larger framework I'm building, I'm trying to start up a
> sclang instance with a yaml configuration set to include an custom
> extension I wrote. However, if the user already has that extension in
> their extensions directory, this causes the library not to compile
> successfully, due to a duplicate class definition.
>
> Is there a way, before defining a class, to check whether it's already
> defined, and if so skip it?

No, not currently. The main problem with that concept is: If you have
two definitions of a class in different files, which one takes effect
and which one should be skipped? There is no way to determine from the
contents of the code files, and every other criterion you could think
of (say, which one has the later date in the filesystem) is likely to
fail under some circumstance.

Designing installation packages for extensions is... tricky in SC.
Currently we don't have an automated way in SC code to manage
conflicts.

This problem might be one for your package's readme: If the user
already has the extension in their Extensions directory, they should
delete it before installing the new package.

hjh

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/