jsoftware / jsource

J engine source mirror
Other
658 stars 90 forks source link

False domain error reported when name of expected verb instead refers to a noun #207

Open cchando opened 2 months ago

cchando commented 2 months ago
   f=: N+]
   N=: 3
   f 1
|domain error in N, executing monad N
|       f 1

Because N wasn't defined at the time that f was, it was assumed to be a verb. When the execution of [N as a verb] was attempted, an error was raised because it instead referred to a noun.

This is reported as a domain error, which it is confusing; it should be interpreted as a value error since it concerns N's part-of-speech only. It might say e.g.

|value error in N, executing monad N: N was expected to be a verb, but is defined as a noun
|       f 1

Perhaps better would be to instead attempt to interpret N as a noun and apply the containing expression accordingly, upon the interpreter seeing that N is a noun (or just as a general fallback to attempted verb interpretations). This latter suggestion might not be feasible, depending on implementation details.

HenryHRich commented 2 months ago

Agreed that domain error is misleading. 'value error'means undefined name. This is a /pun in type/, where JE analyzed a phrase using the parts of speech of the defined names, and later, when the result of the analysis was to be used, a name had a different type. Worth a better message, I agree.

Henry Rich

On Sat, Aug 17, 2024, 11:52 PM Cameron Chandoke @.***> wrote:

f=: N+] N=: 3 f 1 |domain error in N, executing monad N | f 1

Because N wasn't defined at the time that f was, it was assumed to be a verb. When the execution of [N as a verb], an error was raised because it instead referred to a noun.

This is reported as a domain error, which it is confusing; it should be interpreted as a value error since it concerns N's part-of-speech only. It might say e.g.

|value error in N, executing monad N: N was expected to be a verb, but is defined as a noun | f 1

Perhaps better would be to instead attempt to interpret N as a noun and apply the containing expression accordingly, upon the interpreter seeing that N is a noun (or just as a general fallback to attempted verb interpretations). This latter suggestion might not be feasible, depending on implementation details.

— Reply to this email directly, view it on GitHub https://github.com/jsoftware/jsource/issues/207, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEKVAJ62ZGTB3FZGPQYJP4LZR7HZRAVCNFSM6AAAAABMVZBGVWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQ3TCNRZHEZTOMI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

HenryHRich commented 2 months ago

New message coming in next beta

Henry Rich

On Sun, Aug 18, 2024, 7:44 AM Henry Rich @.***> wrote:

Agreed that domain error is misleading. 'value error'means undefined name. This is a /pun in type/, where JE analyzed a phrase using the parts of speech of the defined names, and later, when the result of the analysis was to be used, a name had a different type. Worth a better message, I agree.

Henry Rich

On Sat, Aug 17, 2024, 11:52 PM Cameron Chandoke @.***> wrote:

f=: N+] N=: 3 f 1 |domain error in N, executing monad N | f 1

Because N wasn't defined at the time that f was, it was assumed to be a verb. When the execution of [N as a verb], an error was raised because it instead referred to a noun.

This is reported as a domain error, which it is confusing; it should be interpreted as a value error since it concerns N's part-of-speech only. It might say e.g.

|value error in N, executing monad N: N was expected to be a verb, but is defined as a noun | f 1

Perhaps better would be to instead attempt to interpret N as a noun and apply the containing expression accordingly, upon the interpreter seeing that N is a noun (or just as a general fallback to attempted verb interpretations). This latter suggestion might not be feasible, depending on implementation details.

— Reply to this email directly, view it on GitHub https://github.com/jsoftware/jsource/issues/207, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEKVAJ62ZGTB3FZGPQYJP4LZR7HZRAVCNFSM6AAAAABMVZBGVWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQ3TCNRZHEZTOMI . You are receiving this because you are subscribed to this thread.Message ID: @.***>