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

Delay arithmetic syntax error #2458

Draft
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

hurufu
Copy link
Contributor

@hurufu hurufu commented Jul 23, 2024

PR for fixing #2454 issue.

Please review unit test that I've added, does it correctly describe the problem at hand? And does it make sense to add such a long running test?

@hurufu hurufu force-pushed the delay-arithmetic-syntax-error branch 2 times, most recently from 30a2978 to a2ddc6c Compare July 31, 2024 23:03
@hurufu hurufu force-pushed the delay-arithmetic-syntax-error branch from 6de57a2 to e92db0c Compare August 3, 2024 20:32
@mthom
Copy link
Owner

mthom commented Aug 3, 2024

I'm not sure what a satisfactory solution for #2454 should look like but I am hesitant to detect it from goal_expansion like we do for dcgs. It may make more sense to modify compile_is to generate code issuing an error at runtime rather than at compile time.

@hurufu
Copy link
Contributor Author

hurufu commented Aug 4, 2024

Thanks a lot for suggestion. I also initially wanted to modify compiler code, but it explicitly produces an error if string is found that's why I made a conclusion that it is designed to throw an exception at compile time, and maybe it is even a good idea to show to the user that compilation wasn't successful... So I changed my general idea to do this rewrite (example): A is sqrt([]) ==> []=B, A is sqrt(B) behavior is the same, but error is delayed to the runtime. Also proper solution should be working both for consulting a file or asserting new predicate, and I'm not sure if goal expansion is done for assertions.

I don't have much time this weekend, I'll take a fresh look into the code next week probably and will see what it takes generate code that will issue an error.

@mthom
Copy link
Owner

mthom commented Aug 5, 2024

I don't have much time this weekend, I'll take a fresh look into the code next week probably and will see what it takes generate code that will issue an error.

You may want to look at diag.pl and the instr! macro. diag.pl will give you examples of the WAM code to generate with instr!, starting from e.g.

f(X) :- throw(error(evaluable, X)).

Then wam_instructions(f/1, Is).

@hurufu hurufu mentioned this pull request Oct 8, 2024
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

Successfully merging this pull request may close these issues.

2 participants