Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
String Slicing (*solved*)
#3
Wouldn't it produce faster code to get the preprocessor to do it?

That is if the --sinclair flag is on:

turn f$( TO ) -> f$

and f$( 7 TO 10) -> f$(6 TO 9)

before the compiler sees it.

This saves the compiled code from having to make the adjustments at run time, yes?

Yes - I know, if it's f$(a TO b) - we can't do that so easily, and we'll have to dec the number before we use it; which means that being less compatible will be faster code. But it's a thought to optimization if the string is sliced by constants.

You probably can't preprocess f$(7) so easily, because I suspect the preprocessor couldn't know if it's an array or a string variable. In this case, the compiler needs to be able to recognize that's a fair format for string variables, and means a slice of it.

Incidentally, I found out that fixed size strings don't seem to be supported:

Dim a$(10,5) makes a 2D array of variable length strings, not 10 strings of length 5; so you can't access a$(3) as you can in Sinclair basic.

It's a niggle, but I suspect that there are compiler optimizations that could be made if we know the strings are fixed in length - and, of course, if our aim is ever to be able to straight compile any Sinclair Basic program, it's another incompatibility issue.

I'm not sure if the compiler should really ever be able to deal with a Sinclair program with no modifications, but it's one possible goal.


For the record, Boriel; I come here and post problems and bug issues. It sounds like I only complain.
But I'm a BIG fan of the work, I think it's awesome. Don't ever forget that! You've done a fantastic job so far!


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)