Talk:Bitmap: Difference between revisions

Line 23:
 
A good comment could succinctly convey the purpose of the verb, and even help catch errors in the implementation, which may go unnoticed even with some examples of use. Without phrases like "For the basic bitmap structure, this way to store data is likely the most convenient and natural for manipulating with J." one could wonder why this particular data structure was chosen for the task in hand. [[User:Avmich|Avmich]] 17:57, 29 August 2009 (UTC)
 
:I totally agree that standalone code should describe the purpose and interface of the verbs/functions defined. However on this site (and for this page) the task description at the top of the page lays out the spec for each of the verbs given, the choice of name for each of those verbs makes it clear which is which rendering the repetition of that spec superfluous and in my opinion it actually detracts from the impact of the entry. None of the other languages repeat that description for each of their functions or document their interfaces, in fact many have no comments at all! I think that the commented example usage section shows more succinctly and clearly the interface for the verbs than a description would.
 
:Regarding the comment re choice of structure - in my opinion the idea of the task (and site in general) is to show how "best" to complete a task using various languages. The default assumption therefore, is that the approach shown for a language ''is'' the most convenient and natural method. If it is not, then a comment would certainly be appropriate, or perhaps the less natural approach should be replaced with a more natural approach for the language.
 
:Regarding the <tt>allocImage</tt> and <tt>fillImage</tt> verbs, I'm not sure the current definition for <tt>fillImage</tt> is really "filling" an existing image, instead it creates a new image with the same shaped structure as an existing one. I think the main issue here is that allocating an uninitialized image isn't really "natural" in J. Instead it would probably be more common to combine the two steps as one. Maybe it would be better to make that comment and replace the current definitions of <tt>allocImage</tt> and <tt>fillImage</tt> with the following which takes the desired size as the right argument, with an optional left argument specifying the colour with black as the default? --[[User:Tikkanz|Tikkanz]] 00:38, 30 August 2009 (UTC)
 
<lang j>createImage=: 0&$: : ($~ 3 ,~ ])
myimg=: createImage 7 5 NB. create a 7 by 5 bitmap (black)
myimg=: 255 255 255 createImage 7 5 NB. create a 7 by 5 white bitmap</lang>
892

edits