No Result for ⎕R?

General APL language issues

No Result for ⎕R?

Postby paulmansour on Fri May 26, 2017 4:15 pm

I' surprised that ⎕R does not return some sort of result when the output is streamed. Were the in-house dfnistas asleep at the wheel when this was being designed? ;)

Perhaps it would be useful to have it return the number of replacements or blocks processed or something.
paulmansour
 
Posts: 420
Joined: Fri Oct 03, 2008 4:14 pm

Re: No Result for ⎕R?

Postby JohnS|Dyalog on Tue May 30, 2017 8:44 am

Thanks for this - it was an oversight - we're on it.
The suggestion is that, in this case, ⎕R return the same (shy) result as ⎕NAPPEND: the file offset in bytes of the end of the new data.
JohnS|Dyalog
 

Re: No Result for ⎕R?

Postby paulmansour on Tue May 30, 2017 1:35 pm

Sounds good to me. Thanks!
paulmansour
 
Posts: 420
Joined: Fri Oct 03, 2008 4:14 pm

Re: No Result for ⎕R? What about ⎕CY

Postby petermsiegel on Thu Jun 01, 2017 3:58 am

Since we're on the subject, any reason why ⎕CY should not return a value (similar to ⎕EX). In a DFN, one is forced to use execute ⍎'this that ⎕CY myWS ⋄ 1' or some such. Thanks.
petermsiegel
 
Posts: 143
Joined: Thu Nov 11, 2010 11:04 pm

Re: No Result for ⎕R?

Postby paulmansour on Thu Jun 01, 2017 1:07 pm

Yes, please!

I'm usually doing something like

      {0::0 ⋄ z← ... ⎕CY ...}


somewhere I have operator for doing this....

I think when dfns were first introduced, there was a flurry of activity to retrofit any non result returning quad functions. A few were left behind.
paulmansour
 
Posts: 420
Joined: Fri Oct 03, 2008 4:14 pm

Re: No Result for ⎕R?

Postby AndyS|Dyalog on Thu Jun 01, 2017 3:44 pm

Regarding Peter's comment about ⎕CY: although we won't be changing ⎕CY in 16.0, we are thinking about it for 17.0, along with changing all the other non-result returning system functions too.
User avatar
AndyS|Dyalog
 
Posts: 257
Joined: Tue May 12, 2009 6:06 pm

Re: No Result for ⎕R?

Postby petermsiegel on Fri Jun 02, 2017 9:22 pm

Thanks. Shy results were the best idea ever-- have your cake and eat it, too.
petermsiegel
 
Posts: 143
Joined: Thu Nov 11, 2010 11:04 pm

Re: No Result for ⎕R?

Postby Morten|Dyalog on Sat Jun 03, 2017 12:43 pm

Shy results may be cute, but IMHO they are nasty at the language/implementation level, as they require a function to know whether its result will be used. If I were starting again with a clean slate I would argue long and hard against them. There are so many edge cases that it quickly spirals out of control. Consider:

Code: Select all
     shydup←{r←⍵ ⍵}
     shydup 2
     shydup¨2
     (shydup⍣1)2 3


So far so good, but will you demand that we also special-case operators that need the values to assemble a result?

Code: Select all
     (shydup⍤0)2 3
2 3
2 3
     shydup⌸1 2
 1  1
 2  2


And what about asynchronous calls, like:

Code: Select all
     future←isolate.shydup 1


The function cannot know whether its result will be used, that hasn't been decided yet.

I don't personally feel that the utility of shyness is worth the implementation complexity. One man's view :-).
User avatar
Morten|Dyalog
 
Posts: 453
Joined: Tue Sep 09, 2008 3:52 pm

Re: No Result for ⎕R?

Postby Phil Last on Sun Jun 04, 2017 9:42 am

Two. 'though ALL functions should return a result. Just not a shy one.
      ∇f00∇
∇f00←{
[1] r←⍵
[2] }

∇f01∇
∇f01←{
[1] f00 ⍵
[2] }

f00 2
⍝ OK?
⎕←f00 2
2
⍝ OK
f01 3
⍝ NOT OK
⎕←f01 3
VALUE ERROR: No result was provided when the context expected one
f01[1] f00 ⍵

⍝ WHAAAAAT???????????????
User avatar
Phil Last
 
Posts: 628
Joined: Thu Jun 18, 2009 6:29 pm
Location: Wessex

Re: No Result for ⎕R?

Postby Morten|Dyalog on Sun Jun 04, 2017 10:51 am

Yay, I am not alone :-)

Since I feel encouraged, I will add:

* All functions SHOULD return a result (or they are not really functions, are they - functions map data from one domain to another).
* The result SHOULD always be displayed at a six space prompt (unless you "sink" it).
* The result of an expression within a TradFn body SHOULD NOT be displayed unless there is an explicit ⎕←.
User avatar
Morten|Dyalog
 
Posts: 453
Joined: Tue Sep 09, 2008 3:52 pm

Next

Return to Language

Who is online

Users browsing this forum: No registered users and 1 guest