I'd probably do conew ;coname''

I do not like changing existing interfaces because that's almost sure
to break something down the line (here, your code depends on the
modified conew, so would fail when someone tries to use it on an
unmodified instance of J, which includes an instance of J which
somehow protects conew from being modified -- not likely in the short
term but who knows where we'll be in a couple decades...).

That said, I see nothing wrong with using boxopen here. Or, for that
matter, c=. <;y

Thanks,

-- 
Raul

On Thu, Jul 16, 2020 at 12:44 AM David Lambert <[email protected]> wrote:
>
> I need an object to create an instance of same class.
> Solution, unbox and re-box
> value conew 0 {:: coname''
>
> Is this a common need?  Does putting boxopen into conew break code?  If
> not, we could use
> value conew coname''
>
> conew=: 3 : 0
>  c=. boxopen y           NB. was  c=. <y
>  obj=. cocreate''
>  coinsert__obj c
>  COCREATOR__obj=: coname''
>  obj
>  :
>  w=. conew y
>  create__w x
>  w
> )
>
> Thanks, Dave
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to