| Anonymous | Login | Signup for a new account | 02-09-2010 12:32 UTC |
| Main | My View | View Issues | Change Log | Docs |
| Viewing Issue Simple Details [ Jump to Notes ] | [ View Advanced ] [ Issue History ] [ Print ] | ||||||||||||
| ID | Category | Severity | Reproducibility | Date Submitted | Last Update | ||||||||
| 0006426 | [Squeak] Compiler | feature | always | 04-18-07 14:42 | 02-23-09 06:52 | ||||||||
| Reporter | sig | View Status | public | ||||||||||
| Assigned To | Keith_Hodges | ||||||||||||
| Priority | normal | Resolution | open | ||||||||||
| Status | resolved | Product Version | 3.9 | ||||||||||
| Summary | 0006426: ifNotNil: don't accept monadic blocks | ||||||||||||
| Description |
(someObject message) ifNotNil: [ :obj | .... <- argument of ifNotNil: must be a 0-argument block -> ] |
||||||||||||
| Additional Information | i don't know if this an issue, because this method used only in compiler definitions and only in one place in real code, except from mine. | ||||||||||||
| Attached Files |
|
||||||||||||
|
|
|||||||||||||
Relationships |
|||||||||||
|
|||||||||||
Notes |
|
|
(0010579 - 217 - 241 - 241 - 241 - 241 - 241) wiz 04-18-07 20:35 edited on: 04-18-07 20:43 |
Huh? I know there is an issue here but I get confused from the description. Can you give two examples (one that works and one that doesn't) and say again what you think should be true when this works as you wish. |
|
(0010588 - 447 - 507 - 507 - 507 - 507 - 507) sig 04-19-07 04:28 |
ok ok. sample 1 (someObject message) ifNotNil: [ someOtherObject and some more code ]. sample 2 (someObject message) ifNotNil: [ :notNilValue | self now i can use: notNilValue ]. Note, both samples is correct use of this method. Because if you see #ifNotNil: implementation , it uses #valueWithPossibleArgs: method to enter block closure. But when i compile sample 2 - compiler insists that i can use it only in form like sample 1. |
|
(0010592 - 1076 - 1280 - 1280 - 1429 - 1429 - 1429) wiz 04-19-07 19:23 edited on: 04-19-07 20:54 |
cool, Now I understand. nil ifNotNil: [ :each | nil inform: each printString <- argument of ifNotNil: must be a 0-argument block ->] 8 ifNotNil: [ nil inform: nil printString ] nil nil ifNotNil: [ nil inform: nil printString ] nil were my workspace examples. Confirming your point. I seem to remember discussion along the lines of this being due to inlining (i.e. its handled as a special case by the compiler.) So I think it would be quite hard to fix. (Compiler or vm level.) However I maight be mistaken. Lets see if anyone else has an idea. Ah, found the reference see 0004867. Marcus's decision was just to change to code to follow what the compiler actually does. So it looks like that will be the resolution. The message #ifNotNilDo: is the form that takes and argument Note: From the view issues page you can research past reports by putting in a search phrase (e.g. I used ifnotnil) and pressing the nearby button. Welcome and thanks for helping improve squeak with your reports. Yours in service, --Jerome Peace |
|
(0010594 - 567 - 940 - 940 - 940 - 940 - 940) sig 04-20-07 18:15 |
i dont know if #ifNotNil: described in ANSI protocol, but in VW its declared as following: ifNotNil: aBlock "If the receiver is not nil, answer the evaluation of aBlock (with the receiver as its argument if it takes one), otherwise answer nil. Since the receiver is not nil, answer aBlock's evaluation. Passing the receiver to aBlock is handy for idioms such as self toolBarSpec ifNotNil: [:spec | ...]. UndefinedObject reimplements this to not evaluate aBlock." ^0 == aBlock numArgs ifTrue: [aBlock value] ifFalse: [aBlock value: self] |
|
(0010603 - 301 - 313 - 651 - 651 - 651 - 651) vassili 04-23-07 09:10 edited on: 04-23-07 09:10 |
By an interesting coincidence I just wrote up an analysis and posted the compiler fix on my blog http://blog.3plus4.org/2007/04/22/notnil-then-what. [^] Thanks to Lukas Renggli for pointing me here. Here is a direct link to the fix: http://blog.3plus4.org/wp-content/uploads/2007/04/monadicifnotnil.zip. [^] |
|
(0010607 - 229 - 247 - 247 - 247 - 247 - 247) sig 04-23-07 15:17 edited on: 04-23-07 15:18 |
vassili, thanks for a long description which supports my point of view. If #ifNotNil: accepts only nulladic blocks then there is totally no reasons to introduce it at all, because it simply can be replaced by isNil IfFalse: [] |
|
(0010822 - 195 - 195 - 195 - 195 - 195 - 195) pdcawley 06-21-07 06:49 |
The ifNotNilFix.1.cs changeset I just uploaded contains a simple fix to the optimizer to make ifNotNil: behave as implemented without ditching the optimization where the block has zero arguments. |
|
(0010824 - 77 - 101 - 101 - 101 - 101 - 101) wiz 06-22-07 00:06 |
Reminder sent to: MarcusDenker Hi marcus, Your feedback could clinch it. Would you recommend this fix? |
|
(0012979 - 118 - 124 - 124 - 124 - 124 - 124) MarcusDenker 02-22-09 18:50 |
The solution is to adopt vassili's code ASAP. (it's in Pharo since a couple of Months, in NewSpeak sind he wrote it). |
|
(0012981 - 190 - 190 - 190 - 190 - 190 - 190) KenCausey 02-22-09 22:23 |
I'm just about the last person to be judging compiler changes, but in my opinion MonadicIfNotNil.1.cs addresses everything that ifNotNilFix.1.cs and more. There is no value in loading both. |
|
(0012982 - 235 - 321 - 321 - 321 - 321 - 321) matthewf 02-23-09 03:58 |
Fixed some underscore assignments "fix begin" Installer mantis bug: 6426 fix: 'M6426-MonadicIfNotNil-mtf.2.cs'. "Vassili's fix" "fix test" Installer mantis bug: 6426 fix: 'MonadicIfNotNilTests.1.cs'. "Vassilli's tests" "fix end" |
| Mantis 1.0.8[^]
Copyright © 2000 - 2007 Mantis Group
139 total queries executed. 63 unique queries executed. |