J: explicit vs. tacit definitions 
Author Message
 J: explicit vs. tacit definitions

Are tacit and explicit definitions supposed to act as differently as
they do? Specifically (using 4.06d),

==========
   a=: 3 : '(''text is: ''"_ , text"_) y.'
   b=: 13 : '(''text is: ''"_ , text"_) y.'
   a
+-+-+---------------------------+
|3|:|('text is: '"_ , text"_) y.|
+-+-+---------------------------+
   b
+---------------+-+----------+
|+---------+-+-+|,|+----+-+-+|
||text is: |"|_|| ||text|"|_||
|+---------+-+-+| |+----+-+-+|
+---------------+-+----------+
   a ''
|value error: text
|       ('text is: '"_,text"_)y.
   b ''
|value error: text
|       b''
   NB. so far, so good.
   text=: 'foobar'
   a ''
text is: foobar
   NB. which is what I would expect
   b ''
|domain error: text
|       b''
   NB. this is a surprise to me.
   b=: 13 : '(''text is: ''"_ , text"_) y.'
   b ''
text is: foobar
   NB. why did I have to redefine 'b'?
   text=: 'goobaz'
   a ''
text is: goobaz
   NB. as it 'should' be
   b ''
text is: foobar
   NB. it seems I have to redefine 'b' again!
   b
+---------------+-+------------+
|+---------+-+-+|,|+------+-+-+|
||text is: |"|_|| ||foobar|"|_||
|+---------+-+-+| |+------+-+-+|
+---------------+-+------------+
   b=: 13 : '(''text is: ''"_ , text"_) y.'
   b
+---------------+-+------------+
|+---------+-+-+|,|+------+-+-+|
||text is: |"|_|| ||goobaz|"|_||
|+---------+-+-+| |+------+-+-+|
+---------------+-+------------+
   NB. it looks like the DEFINITION changed
   b ''
text is: goobaz
==========

IOW, the explicit definition, 'a', seems to evaluate the global noun
'text' at execution, whereas the tacit definition, 'b', seems to
evaluate 'text' at definition.

Is this the way things are meant to be?

____________________________________



Sat, 10 Jul 2004 22:40:04 GMT  
 J: explicit vs. tacit definitions

Quote:

>   NB. why did I have to redefine 'b'?

In a tacit definition, unknown identifiers are assumed to be verbs
and are grammatically treated as such -- at definition time, when
the text is "compiled".  When you later (re-)defined "text" to be
a noun, that caused a clash with the initial default assumption.
The redefinition fixed that clash.

An explicit defintion is not parsed at definition time.  It will
be parsed (again and again) during execution of the verb etc.

The implicit verb assumption makes it easy and elegant to write
mutual recursive functions, but I wonder whether it caused more
harm then benefits for the user base in real life.

                                                Martin Neitzel



Mon, 12 Jul 2004 07:50:21 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. J: explicit vs. tacit definitions

2. J2 explicit to tacit defs

3. function dependencies and tacit definitions (J)

4. Testing for tacit definitions in J

5. J: Nested explicit definitions: scope of names?

6. Explicit definition of a conjunction.

7. newFromOld explicit definition translation utility?

8. newFromOld explicit definition translation utility?

9. Problem with J table adverb & explicit definition

10. Explicit Definition

11. Explicit definition

12. Explicit definition

 

 
Powered by phpBB® Forum Software