Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some issues with SparForte and the language #13

Open
specing opened this issue Apr 28, 2018 · 12 comments
Open

Some issues with SparForte and the language #13

specing opened this issue Apr 28, 2018 · 12 comments

Comments

@specing
Copy link

specing commented Apr 28, 2018

All issues based on 2eb28f7:

  1. the rules around end loop;, end if;, end <name>;, ... could be made more lax such that end; would be enough.

  2. Is there a way to read a number in arbitrary base? Specifically numerics.value does not understand 0x... notation.

  3. Huh? Shouldn't it be an exception?

raise constraint_error with "String repr does not start with 0x";
      ^--------------^ constraint_error is a variable not an exception
  1. How does one use rem and mod in scripts?
case 20 rem 16 is
     ^^ identifier expected, not a number
case n rem 16 is
       ^-^ is expected
=> ? 20 rem 16
 4
  1. Command completion in shell mode is not working

  2. When spar is restarted, command lines issued from previous sessions are not loaded.

  3. neither start-up greeting Type "help" for help nor help print SparForte version.

  4. pkg_cmdline.html: s := command_name - number of environment vars in documentation is wrong? (it does not make sense).

@specing
Copy link
Author

specing commented Apr 28, 2018

  1. when 0-9 => syntax does not work

note for 4: r := n rem 16; works.

  1. Sometimes it does not warn/error out when a function has no return statement. It could be related to a raise being nested inside.

  2. How does one do simple integer division? natural /constant produces a real number.

  3. Unable to define two functions with the same name but different types in argument lists (string and character).

@kburtch
Copy link
Owner

kburtch commented Apr 28, 2018

  1. In SparForte, the syntax rules are that end must be follow with a word describing what is being ended. This not only checks for criss-crossed designs, but is helpful when conditional and loop statements are very long. While it is certainly possible to make the second word optional, it is intentionally designed this way to improve code quality and readability.

  2. SparForte uses the Ada notation for bases, not the C convention. That is, base#value#. I cannot remember if that's fully supported throughout the language or not. It's been a long time since I used it.

  3. This is lacking context. Did you declare constraint_error as an exception? It is not a built-in exception.

  4. A case statement always takes a single variable, not an expression.

  5. "Command completion in shell mode is not working". It works for me. Can you give an example?

  6. SparForte doesn't save your commands to a history file or reload them on startup. That's not implemented.

  7. The SparForte version can be see with spar -V, or using the System package.

  8. Yes, it sounds like the documentation is incorrect.

  9. The syntax is when 0..9 =>.

  10. Since I recently added raise...when and return..when, that is, since I made them conditional, SparForte can no longer be certain that simply seeing "raise" or "return" and further statements is unreachable code. This is a known issue.

  11. In SparForte, all literal numbers of universal_numeric (which is a float type). You can cast number results to an integer with integer() or assign the values to an integer variable, which implicitly casts the results. For example, i : integer := 3/2; should work as you expect.

  12. Correct. SparForte does not have name overloading. At least, not yet. Each function requires a unique name.

@kburtch
Copy link
Owner

kburtch commented Apr 28, 2018

@specing
Copy link
Author

specing commented Apr 28, 2018

  1. Cannot rename this?
type BadSectorList is new doubly_linked_lists.list(natural);
                                                  ^ doubly_linked_lists.list is a generic type, not a type or a subtype
  1. ???
        function read_map_file (path: string) return doubly_linked_lists.list(natural) is
                                                                             ^ is expected

@specing
Copy link
Author

specing commented Apr 28, 2018

  1. That is reasonable for long pieces of code, but could this be made optional if e.g. there is not more than 10 lines between start and end? With a loop on 3 lines it IMO makes readability worse.

  2. Ok, but when script it can reasonably be expected that we will also need to parse the C convention of giving numbers in different bases (such as me right now).

  3. I did not as Spar itself gave me a constraint error before so I had assumed it would be built-in.

  4. Why?

  5. => bas should print 5 suggestions, but nothing happens. Similarly => bashd... should complete to "bashdb" but nothing happens. Does spar expect a different character than TAB?

  6. spar -V on a non-release version still gives me the last release,. Usually dev builds of programs print
    last_release + number_of_commits + commit_id or similar.

  7. I see. No idea what had me try to subtract in there.

@specing
Copy link
Author

specing commented Apr 29, 2018

when 0..9 => s := strings.val(numerics.pos('0') + r)      & s;
      ^^ '=>' expected

@kburtch
Copy link
Owner

kburtch commented Apr 29, 2018

Thank you for your questions and feedback. For general questions on SparForte, you can sign up to the mailing list on the website.

  1. I understand your concern about readability. I want to keep things simple and consistent. I do not think "end if" reduces readability.

  2. It depends on priority, time and contributors willing to tackle this issue. This is a project done in my free time. I will note this issue in the TODO file, if it is not there already. For now, can use convert the number to base 10?

  3. That appears to be a sparforte bug. It should say the identifier is not declared. I will note this in the TODO file.

  4. That is the restriction in the Ada language on which SparForte is based. The Ada Reference or Rationale Manuals may give insight into the decision. As it hasn't been anissue, I haven't changed the behaviour in SparForte.

  5. SparForte uses the same GNU readline library as Bash, and has the same behaviour. Pressing tab once autocompletes if there's only one match. Pressing tab twice shows a list of the alternatives.

  6. I'm not doing anything so elaborate with the version numbers. I usually increment the number one over the previous release. Releases are relatively slow.

  7. Double-checking the documentation...case ranges aren't supported yet. You can achieve the same effect using if statements. I will make a note in the TODO file.

if i in 1..5 then

  1. Parameterized built-in types are a recent feature. I don't think these types can be renamed yet with type or subtype.

  2. Only scalar types can be used in expressions and returned. This is a known limitation. I have to rewrite the expression parsing to support multiple values. Try using a global variable for the linked list, if that is possible.

Ken B.

@kburtch
Copy link
Owner

kburtch commented May 6, 2018

The incorrect error message when raising a non-existent exception has been fixed.

@kburtch
Copy link
Owner

kburtch commented May 15, 2018

SparForte's configure script now has a "released" flag. Development builds (not including the --released flag) will have the build date in the prompt and in the -V version message.

@specing
Copy link
Author

specing commented May 15, 2018

How about having configure run git describe, which at the latest head returns v2.1-142-g26a640d and putting that into src/world.ads.orig where the version is hardcoded? After git checkout v2.1 it naturally returns v2.1.

@kburtch
Copy link
Owner

kburtch commented May 21, 2018

Well, (1) the project doesn't necessarily run under Git, so it would have to be optional; (2) what is the priority on this over the other concerns you have?

@specing
Copy link
Author

specing commented May 22, 2018

(1) It does not run under git, but it is compiled under git and the result of git describe can be hardcoded into SparForte. Similarly when a release is done, the release script can run this in order for the source distribution package to have the correct version.
(2) there is no priority for any of them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants