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

tweak some error messages to be more like WMA... #1094

Merged
merged 5 commits into from
Sep 26, 2024

Conversation

rocky
Copy link
Member

@rocky rocky commented Sep 25, 2024

in particular Get::noopen, {First,Last,Most}::normal

in particular Get::noopen, {First,Last,Most}::normal
@rocky rocky requested a review from mmatera September 25, 2024 23:47
@@ -589,24 +590,24 @@ class First(Builtin):
>> First[a + b + c]
= a
>> First[x]
: Nonatomic expression expected.
: Nonatomic expression expected at position 1 in First[x].
= First[x]
>> First[{}]
: {} has zero length and no first element.
= First[{}]
"""

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First and Lastshould have a default value as second arg and attribute A_HOLD_REST.

Copy link
Contributor

@mmatera mmatera Sep 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@axkr, you are right:

In[1]:= First[a]                                                                

First::normal: Nonatomic expression expected at position 1 in First[a].

Out[1]= First[a]

In[2]:= First[a, b]                                                             

Out[2]= b

In[3]:= First[a, b, c]                                                          

First::argt: First called with 3 arguments; 1 or 2 arguments are expected.

Out[3]= First[a, b, c]

In[4]:= ?? First                                                                

Out[4]= First[expr] gives the first element in expr
         
        >    . First[expr, def] gives the first element if it exists, or def

         
        >       otherwise.


        Attributes[First]={HoldRest, Protected}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - this should be handled now.

Properties on First and Last should be A_HOLD_REST (axel)
Check that arguments are 1 or 2 (mmatera)
and len == 2
and isinstance(first_elem, Atom)
):
return expr.elements[1].evaluate(evaluation)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a comment: to call the evaluate(evaluation) method at the end is not needed: it is going to be called in the next rewrite_apply_eval iteration

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok - thanks. Will remove the explicit call.

Copy link
Contributor

@mmatera mmatera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Merge when you feel it is ready.

@rocky rocky merged commit 3ec8460 into master Sep 26, 2024
11 checks passed
@rocky rocky deleted the tune-Elements-of-Lists-msgs branch September 26, 2024 14:39
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.

3 participants