Author Topic: uses and includes  (Read 3930 times)

0 Members and 1 Guest are viewing this topic.

Offline troflip

uses and includes
« on: December 07, 2015, 05:06:59 PM »
I'd like to move Companion's Sierra Script syntax a little closer to the original. That means getting rid of *use* statements.

In Sierra's compiler, the alternative was the classdef file (for classes), and individual header files (for public procedures).

The information in those (text) files is essentially what is in the binary .sco format that Brian invented.

Now, the use statements are really just there so the compiler doesn't have to scan *all* sco files in the directory to look for a name match. So it's to speed up the compiler, and partially to scope name matches (but with the small scope of these games, duplicate public procedure names aren't really an issue). So technically, uses could be optional.

So I *could* say, for Sierra Script syntax, they are just optional. I'm not sure if performance would actually be a problem.

For procedures, I could also do what Sierra does, which is require someone to include a header file that has the extern declaration in it:

(extern
     ProcName ScriptNumber ExportNumber
)

The problem is, these are tedious to maintain, since the ExportNumber needs to match what is in the exports statement in that script. I *could* generate a foo.sh header file with the extern statement automatically when you compile a foo.sc script. Of course, there is game.sc, and an already existing game.sh which we don't want to overwrite.

Another alternative is to write all procedures into a single procs.sh file, which could get included by the compiler automatically (or included by sci.sh or something).

Leveraging extern statements is kind of nice, because then kernels can just be a special case of that (like they were with Sierra's compiler). That means you could compile against various different kernel.sh files depending on the interpreter. Instead, I currently have hard-coded kernel function mappings for SCI0/1, SCI2, SCI2.1. But in reality, I think there are cases where each interpreter had a slightly different kernel set (especially for later SCI versions), and this "future-proofs" SCI Companion, because people could adapt it to different interpreters just by modifying kernels.sh.

Just rambling here...


Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline Kawa

Re: uses and includes
« Reply #1 on: December 07, 2015, 05:24:55 PM »
If it's not that big an impact performance-wise, removing the need for (use "X") could be nice. But I'm not sure if the whole thing with the externs is worth the effort, yours or otherwise.

Offline Collector

Re: uses and includes
« Reply #2 on: December 07, 2015, 06:20:59 PM »
I am all for making the scripting language as similar to Sierra's as is reasonable. Two thumbs up! I guess this will require going through all of the old tutorials and code examples to updated to to work with the new Companion/Sierra scripting. I have already started to make some changes to the syntax highlighting for the Wiki. On the plus side this makes the official documentation more relevant. I am working on converting the Script Classes document to Wiki format. It involves the most busy work of any of the documents.
KQII Remake Pic

Offline troflip

Re: uses and includes
« Reply #3 on: December 07, 2015, 06:47:49 PM »
I am working on converting the Script Classes document to Wiki format. It involves the most busy work of any of the documents.

You are aware that the SCI Companion documentation includes docs for all the classes already, right?
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline Collector

Re: uses and includes
« Reply #4 on: December 07, 2015, 08:59:30 PM »
Yes, but I wanted to do the official docs, partly for historical reasons. As well as I wanted it in the Wiki's database for cross referencing with other information in the Wiki. I didn't really want to put your documentation in in case you make changes that would require updating the Wiki each time.
KQII Remake Pic

Offline OmerMor

Re: uses and includes
« Reply #5 on: December 08, 2015, 09:21:24 AM »
I'm with collector on this one: all for historical accuracy  :)
Thanks you troflip for taking the time to do this.

The best win IMO is that we would be able to use the original Sierra "template" game (called System Scripts) with SCI Companion.
Although I hadn't shared the System Scripts yet, I hope I'll be able to do that sometime. If and when that'll happen, I hope SCI Companion could just use them as a drop-in replacement for the current template.

Another win for losing the .sco files is that binaries are not "source control friendly". Textual classdef and header files can be diff'd and merged much more easily.

I also love the idea of declaring kernel functions like regular ones.

Offline troflip

Re: uses and includes
« Reply #6 on: December 10, 2015, 04:52:30 PM »
I think for the time being I'm going to hold off on this. There is already significant churn with the rest of the new syntax and the template game name changes and such. Adding in a whole new way to compiling/linking is just too much at this point, and is adding risk for this version of Companion.

I *do* have the unsupported statements (classdef, selectors, global, extern, etc...) correctly parsing, but they are just ignored (and will produce a warning message). This at least ensures people won't use any reserved keywords and such, when naming classes and variables.
Check out my website: http://icefallgames.com
Groundhog Day Competition


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.049 seconds with 23 queries.