No Result for ⎕R?
14 posts
• Page 1 of 2 • 1, 2
No Result for ⎕R?
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.
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?
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.
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?
Sounds good to me. Thanks!
- paulmansour
- Posts: 420
- Joined: Fri Oct 03, 2008 4:14 pm
Re: No Result for ⎕R? What about ⎕CY
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?
Yes, please!
I'm usually doing something like
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.
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?
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.
-
AndyS|Dyalog - Posts: 257
- Joined: Tue May 12, 2009 6:06 pm
Re: No Result for ⎕R?
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?
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:
So far so good, but will you demand that we also special-case operators that need the values to assemble a result?
And what about asynchronous calls, like:
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 :-).
- 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 :-).
-
Morten|Dyalog - Posts: 453
- Joined: Tue Sep 09, 2008 3:52 pm
Re: No Result for ⎕R?
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???????????????
-
Phil Last - Posts: 628
- Joined: Thu Jun 18, 2009 6:29 pm
- Location: Wessex
Re: No Result for ⎕R?
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 ⎕←.
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 ⎕←.
-
Morten|Dyalog - Posts: 453
- Joined: Tue Sep 09, 2008 3:52 pm
14 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group