Re: [Factor-talk] stack effect
Am Wed, 29 Jul 2015 08:44:20 +0100 schrieb Iain Gray iaing...@ednet.co.uk: Just guessing: Replace [ 0 amount 0 coins = or [ 0 ] with [ 0 amount 0 coins = or [ 0 ] signature.asc Description: PGP signature -- ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
[Factor-talk] stack effect
why do I get the following error? Stack effect declaration is wrong inferred ( x x x -- x x ) declared ( amount coins -- ways ) from this lexical variable :: cc ( amount coins -- ways ) 0 amount = [ 1 ] [ 0 amount 0 coins = or [ 0 ] [ amount coins 1 - cc amount coins denominations at* drop - coins cc + ] if ] if ; -- ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] Does the location of the image file matter ?
Am Tue, 28 Jul 2015 23:41:59 +0200 schrieb Björn Lindqvist bjou...@gmail.com: I'm not sure I understand you. By default, resource: is setup as an alias the the directory containing the image file. But you can override it: factor -resource-path=/bla/bla -i=factor.image Essentially, resource: is just a convenient alias and you are free to put your vocab roots anywhere on the filesystem. For example, you could add . first on the vocab roots and then you'd have a vocab lookup similar to how Python looks up modules. It's about the existing vocabularies. They seem to disappear when I use an image file located elsewhere. Without vocabularies the listener crashes too. So I wrote a script scratchVocabulary.factor: - USING: io io.backend io.pathnames prettyprint ; resource: prepend-path normalize-path . flush vocab: prepend-path normalize-path . flush - With this script I can see that vocab: is affected by the location of the image file: - $ cp /home/pub/factor/factor.image . $ factor-lang scratchVocabulary.factor /home/pub/factor/ /home/pub/factor/core $ factor-lang -i=factor.image scratchVocabulary.factor /home/factor/scratchVocabulary/ /home/factor - The reason seems to be the value of vocab-roots: V{ resource:core resource:basis resource:extra resource:work } So that seems to be intended and I have to live with it. Now I also tried overriding as you suggested. No effect: - $ factor-lang -resource=/home/pub/factor -i=factor.image \ scratchVocabulary.factor /home/factor/scratchVocabulary/ /home/factor - In addition I could not find any documentation about the command line switch -resource. signature.asc Description: PGP signature -- ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] Does the location of the image file matter ?
It's because the switch is -resource-path not just -resource. 2015-07-29 9:11 GMT+02:00 Georg Simon georg.si...@auge.de: Am Tue, 28 Jul 2015 23:41:59 +0200 schrieb Björn Lindqvist bjou...@gmail.com: I'm not sure I understand you. By default, resource: is setup as an alias the the directory containing the image file. But you can override it: factor -resource-path=/bla/bla -i=factor.image Essentially, resource: is just a convenient alias and you are free to put your vocab roots anywhere on the filesystem. For example, you could add . first on the vocab roots and then you'd have a vocab lookup similar to how Python looks up modules. It's about the existing vocabularies. They seem to disappear when I use an image file located elsewhere. Without vocabularies the listener crashes too. So I wrote a script scratchVocabulary.factor: - USING: io io.backend io.pathnames prettyprint ; resource: prepend-path normalize-path . flush vocab: prepend-path normalize-path . flush - With this script I can see that vocab: is affected by the location of the image file: - $ cp /home/pub/factor/factor.image . $ factor-lang scratchVocabulary.factor /home/pub/factor/ /home/pub/factor/core $ factor-lang -i=factor.image scratchVocabulary.factor /home/factor/scratchVocabulary/ /home/factor - The reason seems to be the value of vocab-roots: V{ resource:core resource:basis resource:extra resource:work } So that seems to be intended and I have to live with it. Now I also tried overriding as you suggested. No effect: - $ factor-lang -resource=/home/pub/factor -i=factor.image \ scratchVocabulary.factor /home/factor/scratchVocabulary/ /home/factor - In addition I could not find any documentation about the command line switch -resource. -- ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk -- mvh/best regards Björn Lindqvist -- ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] Does the location of the image file matter ?
Am Wed, 29 Jul 2015 12:00:04 +0200 schrieb Björn Lindqvist bjou...@gmail.com: It's because the switch is -resource-path not just -resource. My mistake. Sorry. signature.asc Description: PGP signature -- ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] stack effect
Georg solved your problem, but in the future you can easily use Factors introspection to see why it complains about stack effects. For example, the first quotation given to the inner if is [ 0 ] and you can infer its stack effect: IN: scratchpad [ 0 ] infer. ( -- x ) Then because the two quotations given to if must have the same stack effect, the second quotation must also have ( -- x ) which you can check like this: ! Needs to be declared because you are using locals IN: scratchpad SYMBOLS: amount coins cc denominations ; IN: scratchpad [ amount coins 1 - cc amount coins denominations at* drop - coins cc + ] infer. ( -- x x x x x ) Or you can manually count the stack delta. Local variables and numbers are +1, binary operations and drop -1 and at* is +/- 0: +1 +1+1 -1 +1 +1 +1+10 -1 -1 +1+1 -1 [ amount coins 1 - cc amount coins denominations at* drop - coins cc + ] 1 + 1 + 1 - 1 + 1 + 1 + 1 + 1 + 0 - 1 - 1 + 1 + 1 - 1 = +5 2015-07-29 9:44 GMT+02:00 Iain Gray iaing...@ednet.co.uk: why do I get the following error? Stack effect declaration is wrong inferred ( x x x -- x x ) declared ( amount coins -- ways ) from this lexical variable :: cc ( amount coins -- ways ) 0 amount = [ 1 ] [ 0 amount 0 coins = or [ 0 ] [ amount coins 1 - cc amount coins denominations at* drop - coins cc + ] if ] if ; -- ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk -- mvh/best regards Björn Lindqvist -- ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] stack effect
many thanks On 29 Jul 2015, at 12:04, Björn Lindqvist bjou...@gmail.com wrote: Georg solved your problem, but in the future you can easily use Factors introspection to see why it complains about stack effects. For example, the first quotation given to the inner if is [ 0 ] and you can infer its stack effect: IN: scratchpad [ 0 ] infer. ( -- x ) Then because the two quotations given to if must have the same stack effect, the second quotation must also have ( -- x ) which you can check like this: ! Needs to be declared because you are using locals IN: scratchpad SYMBOLS: amount coins cc denominations ; IN: scratchpad [ amount coins 1 - cc amount coins denominations at* drop - coins cc + ] infer. ( -- x x x x x ) Or you can manually count the stack delta. Local variables and numbers are +1, binary operations and drop -1 and at* is +/- 0: +1 +1+1 -1 +1 +1 +1+10 -1 -1 +1+1 -1 [ amount coins 1 - cc amount coins denominations at* drop - coins cc + ] 1 + 1 + 1 - 1 + 1 + 1 + 1 + 1 + 0 - 1 - 1 + 1 + 1 - 1 = +5 2015-07-29 9:44 GMT+02:00 Iain Gray iaing...@ednet.co.uk: why do I get the following error? Stack effect declaration is wrong inferred ( x x x -- x x ) declared ( amount coins -- ways ) from this lexical variable :: cc ( amount coins -- ways ) 0 amount = [ 1 ] [ 0 amount 0 coins = or [ 0 ] [ amount coins 1 - cc amount coins denominations at* drop - coins cc + ] if ] if ; -- ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk -- mvh/best regards Björn Lindqvist -- ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk -- ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk