SDLIDE issues and suggestions

Discussions related specifically to the Windows, Linux (86), Mac OS-X and Raspberry Pi editions of BB4W and BBCSDL
Richard Russell
Posts: 272
Joined: Tue 18 Jun 2024, 09:32

Re: SDLIDE issues and suggestions

Post by Richard Russell »

kirkkaf13@gmail.com wrote: Mon 26 Aug 2024, 18:18I am familiar with Javascript as an interpreted language but it's wildly different.
Although arguably off-topic, I would be interested to know in what ways Javascript is "wildly different" since there are perhaps things that could be learned from it.

I am aware that in Javascript one can 'selectively' import functions from modules, so whereas in BBC BASIC using INSTALL makes all the functions and procedures defined in that module available to be called from the program which INSTALLs it, in Javascript one can specify that only some become available. That doesn't strike me as too fundamental.
User avatar
hellomike
Posts: 184
Joined: Sat 09 Jun 2018, 09:47
Location: Amsterdam

Re: SDLIDE issues and suggestions

Post by hellomike »

Can

Code: Select all

#include <stdio.h>
only include the printf() function?
Richard Russell
Posts: 272
Joined: Tue 18 Jun 2024, 09:32

Re: SDLIDE issues and suggestions

Post by Richard Russell »

hellomike wrote: Tue 27 Aug 2024, 12:59 Can

Code: Select all

#include <stdio.h>
only include the printf() function?
No, why do you ask? This is C, a compiled language, so it isn't actually wasting any memory.

The only potential disadvantage, that I can think of, of multiple functions being 'included' in C is the pollution of the global namespace. But that's typically not an issue if you use a naming convention for your own non-static functions.

It's only when you are very concerned about memory usage - the classic example being when running BBCTTY on a Raspberry Pi Pico - that there is a potential disadvantage in the INSTALL statement unconditionally loading more functions than you actually need.

It's one reason to keep BBC BASIC libraries relatively small, rather than merging them into just a few 'super libraries' that contain every function you might need, but at the cost of a large memory footprint.

Nevertheless it would be possible to contrive a user-defined INSTALL replacement which could selectively load only a subset of the contained functions, so long as dependencies could be identified (sometimes, but not always, I include an @ in the name of such dependencies).
User avatar
hellomike
Posts: 184
Joined: Sat 09 Jun 2018, 09:47
Location: Amsterdam

Re: SDLIDE issues and suggestions

Post by hellomike »

You missed the point I was trying to make. Never mind.
Richard Russell
Posts: 272
Joined: Tue 18 Jun 2024, 09:32

Re: SDLIDE issues and suggestions

Post by Richard Russell »

hellomike wrote: Tue 27 Aug 2024, 12:59 Can

Code: Select all

#include <stdio.h>
only include the printf() function?
I answered this question to the best of my ability (despite it being off-topic) but if you're unable or unwilling to explain how I missed the point perhaps you'd consider deleting it. I will then delete my replies to tidy up the forum.
User avatar
hellomike
Posts: 184
Joined: Sat 09 Jun 2018, 09:47
Location: Amsterdam

Re: SDLIDE issues and suggestions

Post by hellomike »

I meant to say that if C doesn't even have this construct, why would the OP expect this ability from BBC BASIC?
I like to leave it at that now. Thanks
Richard Russell
Posts: 272
Joined: Tue 18 Jun 2024, 09:32

Re: SDLIDE issues and suggestions

Post by Richard Russell »

hellomike wrote: Sun 01 Sep 2024, 08:12 I meant to say that if C doesn't even have this construct, why would the OP expect this ability from BBC BASIC?
This is precisely the issue I addressed in my reply which you said "missed the point". I explained in that reply why it's a valuable ability in the case of an interpreted language (like BBC BASIC and Javascript) but not in the case of a compiled language like C.

Anyway the OP didn't express any such expectation. It was I who commented that "I am aware that in Javascript one can 'selectively' import functions from modules", not the OP.

I recognise the value of that ability in the case of an interpreted language, and as I also said in my reply it would be possible to write a user-defined replacement for the INSTALL statement which did only import specified functions, if that was thought worthwhile.