Re: [Factor-talk] Newbie problem with 'first program'
You mounted the Factor DMG, which is normal, but it is read-only, so you are getting an error when trying to write files or create directories inside it. I recommend copying the factor folder from the DMG into somewhere else like /Applications and then it should work fine. On Thu, Jan 18, 2018 at 6:13 PM, Andrew McDowell wrote: > Hi, > I have installed Factor on Mac OS 10.13. I'm trying to work through the > Your first Program section. When I do: "palindrome" scaffold-work, I get > the following error: > Unix system call “mkdir” failed: > Read-only file system (30) > It was called with the following arguments: > "/Volumes/factor/factor/work/palindrome" > 511 > > I have attempted to change the permissions on that read-only directory, > but even as root it will not let me change the permissions, saying it is a > system directory and cannot be changed. > I attempted to move the factor folder to the ~ directory. It will not > allow it to move. Any ideas? > I am not a programmer nor a -nix user, so please consider me a rank newbie > and a dummy. > Andy > > > -- > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > ___ > Factor-talk mailing list > Factor-talk@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/factor-talk > > -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
[Factor-talk] Newbie problem with 'first program'
Hi, I have installed Factor on Mac OS 10.13. I'm trying to work through the Your first Program section. When I do: "palindrome" scaffold-work, I get the following error: Unix system call “mkdir” failed: Read-only file system (30) It was called with the following arguments: "/Volumes/factor/factor/work/palindrome" 511 I have attempted to change the permissions on that read-only directory, but even as root it will not let me change the permissions, saying it is a system directory and cannot be changed. I attempted to move the factor folder to the ~ directory. It will not allow it to move. Any ideas? I am not a programmer nor a -nix user, so please consider me a rank newbie and a dummy. Andy-- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] printf documentation
See this macro: MACRO: add ( n -- quot ) [ \ + ] [ ] replicate-as ; It's "stack effect" depends on the input. IN: scratchpad [ 1 add ] infer . ( x x -- x ) IN: scratchpad [ 2 add ] infer . ( x x x -- x ) So you really can't do much more than say this macro produces some quotation. Then in calling code, we expand the macro and check the resulting body of code has the right stack effect. : foo1 ( a b -- c ) 1 add ; : foo2 ( a b c -- d ) 2 add ; : foo3 ( a b c d -- e ) 3 add ; On Thu, Jan 18, 2018 at 1:04 PM, Doug Coleman wrote: > Oops. > > MACRO: printf ( string -- quot: ( ..a string -- ..b ) ) > MACRO: sprintf ( string -- quot: ( ..a string -- ..b string ) ) > > > > On Thu, Jan 18, 2018 at 3:02 PM John Benediktsson > wrote: > >> MACRO: always produces a quot. >> >> But when it's "called" it's whatever the stack effect of that produced >> quot is when it's expanded into the calling site. >> >> >> >> >> On Thu, Jan 18, 2018 at 12:36 PM, Alexander Ilin >> wrote: >> >>> O-kay... Let me try to ask my question again... >>> >>> I've read the blog post that you linked to. In there I found the >>> following declaration: >>> `*MACRO:* printf ( format-string -- )` >>> >>> This means that the macro takes one argument and removes it from the >>> stack, doesn't put anything back. >>> >>> But in the actual source code of the `formatting` vocab the declaration >>> is: `MACRO: printf ( format-string -- quot )`, which looks as if the >>> `printf` word takes one parameter off the stack and puts one item back on >>> the stack. >>> >>> ... which is not true: it doesn't put a quotation on the stack, because >>> it calls the quotation. >>> >>> So, I have two questions, basically: >>> >>> 1) why not change the declaration in `formatting` to ``MACRO: printf ( >>> format-string -- )` - with no output onto the stack? >>> 2) are `MACRO:`s allowed to have invalid stack effect declaration? Are >>> they somehow exempted from the compiler checks? >>> >>> I'm asking this because the declared stack effect shows up in the >>> documentation, and is confusing. Reading it gives the expression that it >>> should be used with an extra `call` to the produced quotation: >>> `11 "he%do, world" printf call` >>> >>> 18.01.2018, 19:00, "John Benediktsson" : >>> >>> Both of those are macros (basically special words that produce a >>> quotation), so when "called" they are first macro-expanded into a quotation >>> and then that quotation is called, with whatever stack effect it has. >>> >>> IN: scratchpad 1 2 3 "%s %s %s" printf >>> 1 2 3 >>> >>> IN: scratchpad [ "%s %s %s" printf ] infer >>> ( x x x -- ) >>> >>> IN: scratchpad [ "%s %s %s" printf ] expand-macros >>> [ >>> [ present ] 2 ndip [ " " ] 2 ndip [ present ] 1 ndip >>> [ " " ] 1 ndip [ present ] 0 ndip output-stream get >>> [ stream-write ] curry 5 napply >>> ] >>> >>> Maybe the article I wrote when developing it would help: >>> >>> https://re-factor.blogspot.com/2011/08/printf.html >>> >>> >>> On Thu, Jan 18, 2018 at 4:32 AM, Alexander Ilin >>> wrote: >>> >>> Hello! >>> >>> There are two similar words: printf and sprintf. They have similar >>> stack effects, but different behavior. >>> >>> MACRO: sprintf ( format-string -- result ) >>> leaves a string on stack >>> >>> MACRO: printf ( format-string -- quot ) >>> leaves nothing on stack despite the stack effect specified >>> >>> How come `printf` does'n obey its declared stack effect? >>> >>> ---=--- >>> Александр >>> >>> >>> >>> ---=--- >>> Александр >>> >>> >>> >>> -- >>> Check out the vibrant tech community on one of the world's most >>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot >>> ___ >>> Factor-talk mailing list >>> Factor-talk@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/factor-talk >>> >>> >> >> -- >> Check out the vibrant tech community on one of the world's most >> engaging tech sites, Slashdot.org! http://sdm.link/slashdot__ >> _ >> Factor-talk mailing list >> Factor-talk@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/factor-talk >> > > > -- > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > ___ > Factor-talk mailing list > Factor-talk@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/factor-talk > > -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Re: [Factor-talk] printf documentation
Oops. MACRO: printf ( string -- quot: ( ..a string -- ..b ) ) MACRO: sprintf ( string -- quot: ( ..a string -- ..b string ) ) On Thu, Jan 18, 2018 at 3:02 PM John Benediktsson wrote: > MACRO: always produces a quot. > > But when it's "called" it's whatever the stack effect of that produced > quot is when it's expanded into the calling site. > > > > > On Thu, Jan 18, 2018 at 12:36 PM, Alexander Ilin wrote: > >> O-kay... Let me try to ask my question again... >> >> I've read the blog post that you linked to. In there I found the >> following declaration: >> `*MACRO:* printf ( format-string -- )` >> >> This means that the macro takes one argument and removes it from the >> stack, doesn't put anything back. >> >> But in the actual source code of the `formatting` vocab the declaration >> is: `MACRO: printf ( format-string -- quot )`, which looks as if the >> `printf` word takes one parameter off the stack and puts one item back on >> the stack. >> >> ... which is not true: it doesn't put a quotation on the stack, because >> it calls the quotation. >> >> So, I have two questions, basically: >> >> 1) why not change the declaration in `formatting` to ``MACRO: printf ( >> format-string -- )` - with no output onto the stack? >> 2) are `MACRO:`s allowed to have invalid stack effect declaration? Are >> they somehow exempted from the compiler checks? >> >> I'm asking this because the declared stack effect shows up in the >> documentation, and is confusing. Reading it gives the expression that it >> should be used with an extra `call` to the produced quotation: >> `11 "he%do, world" printf call` >> >> 18.01.2018, 19:00, "John Benediktsson" : >> >> Both of those are macros (basically special words that produce a >> quotation), so when "called" they are first macro-expanded into a quotation >> and then that quotation is called, with whatever stack effect it has. >> >> IN: scratchpad 1 2 3 "%s %s %s" printf >> 1 2 3 >> >> IN: scratchpad [ "%s %s %s" printf ] infer >> ( x x x -- ) >> >> IN: scratchpad [ "%s %s %s" printf ] expand-macros >> [ >> [ present ] 2 ndip [ " " ] 2 ndip [ present ] 1 ndip >> [ " " ] 1 ndip [ present ] 0 ndip output-stream get >> [ stream-write ] curry 5 napply >> ] >> >> Maybe the article I wrote when developing it would help: >> >> https://re-factor.blogspot.com/2011/08/printf.html >> >> >> On Thu, Jan 18, 2018 at 4:32 AM, Alexander Ilin wrote: >> >> Hello! >> >> There are two similar words: printf and sprintf. They have similar >> stack effects, but different behavior. >> >> MACRO: sprintf ( format-string -- result ) >> leaves a string on stack >> >> MACRO: printf ( format-string -- quot ) >> leaves nothing on stack despite the stack effect specified >> >> How come `printf` does'n obey its declared stack effect? >> >> ---=--- >> Александр >> >> >> >> ---=--- >> Александр >> >> >> >> -- >> Check out the vibrant tech community on one of the world's most >> engaging tech sites, Slashdot.org! http://sdm.link/slashdot >> ___ >> Factor-talk mailing list >> Factor-talk@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/factor-talk >> >> > > -- > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > ___ > Factor-talk mailing list > Factor-talk@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/factor-talk > -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] printf documentation
MACRO: always produces a quot. But when it's "called" it's whatever the stack effect of that produced quot is when it's expanded into the calling site. On Thu, Jan 18, 2018 at 12:36 PM, Alexander Ilin wrote: > O-kay... Let me try to ask my question again... > > I've read the blog post that you linked to. In there I found the following > declaration: > `*MACRO:* printf ( format-string -- )` > > This means that the macro takes one argument and removes it from the > stack, doesn't put anything back. > > But in the actual source code of the `formatting` vocab the declaration > is: `MACRO: printf ( format-string -- quot )`, which looks as if the > `printf` word takes one parameter off the stack and puts one item back on > the stack. > > ... which is not true: it doesn't put a quotation on the stack, because it > calls the quotation. > > So, I have two questions, basically: > > 1) why not change the declaration in `formatting` to ``MACRO: printf ( > format-string -- )` - with no output onto the stack? > 2) are `MACRO:`s allowed to have invalid stack effect declaration? Are > they somehow exempted from the compiler checks? > > I'm asking this because the declared stack effect shows up in the > documentation, and is confusing. Reading it gives the expression that it > should be used with an extra `call` to the produced quotation: > `11 "he%do, world" printf call` > > 18.01.2018, 19:00, "John Benediktsson" : > > Both of those are macros (basically special words that produce a > quotation), so when "called" they are first macro-expanded into a quotation > and then that quotation is called, with whatever stack effect it has. > > IN: scratchpad 1 2 3 "%s %s %s" printf > 1 2 3 > > IN: scratchpad [ "%s %s %s" printf ] infer > ( x x x -- ) > > IN: scratchpad [ "%s %s %s" printf ] expand-macros > [ > [ present ] 2 ndip [ " " ] 2 ndip [ present ] 1 ndip > [ " " ] 1 ndip [ present ] 0 ndip output-stream get > [ stream-write ] curry 5 napply > ] > > Maybe the article I wrote when developing it would help: > > https://re-factor.blogspot.com/2011/08/printf.html > > > On Thu, Jan 18, 2018 at 4:32 AM, Alexander Ilin wrote: > > Hello! > > There are two similar words: printf and sprintf. They have similar stack > effects, but different behavior. > > MACRO: sprintf ( format-string -- result ) > leaves a string on stack > > MACRO: printf ( format-string -- quot ) > leaves nothing on stack despite the stack effect specified > > How come `printf` does'n obey its declared stack effect? > > ---=--- > Александр > > > > ---=--- > Александр > > > > -- > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > ___ > Factor-talk mailing list > Factor-talk@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/factor-talk > > -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] printf documentation
We don't really have a solution for this right now. Your stack effects wouldn't match with the convention we have right now of just saying it outputs a ``quot``. I think we need to fix the stack checker to be more exact before we change the code here. This looks more correct but goes against convention: MACRO: printf ( ..a string -- ..b ) MACRO: sprintf ( ..a string -- ..b string ) On Thu, Jan 18, 2018 at 2:50 PM Alexander Ilin wrote: > Can I simply change the stack effects for the purposes of documenting them > like this? > ``` > MACRO: printf ( ... string -- ) > MACRO: sprintf ( ... string -- result ) > ``` > > > 18.01.2018, 23:44, "Doug Coleman" : > > Stack effects on macros are not checked. We have the convention of lying > that the stack effect is ( input -- quot ) but even that is wrong, as the > macro is called immediately so you don't get a quot on the stack. The quot > could have a stack effect of its own but it's variable arity, as you are > seeing with printf. If you have a way to resolve this, lemme know! > > (One idea is "input-only stack effects" which don't have an output, so you > could do ``MACRO: printf ( string ) ... ;``) > > On Thu, Jan 18, 2018 at 2:36 PM Alexander Ilin wrote: > > O-kay... Let me try to ask my question again... > > I've read the blog post that you linked to. In there I found the following > declaration: > `*MACRO:* printf ( format-string -- )` > > This means that the macro takes one argument and removes it from the > stack, doesn't put anything back. > > But in the actual source code of the `formatting` vocab the declaration > is: `MACRO: printf ( format-string -- quot )`, which looks as if the > `printf` word takes one parameter off the stack and puts one item back on > the stack. > > ... which is not true: it doesn't put a quotation on the stack, because it > calls the quotation. > > So, I have two questions, basically: > > 1) why not change the declaration in `formatting` to ``MACRO: printf ( > format-string -- )` - with no output onto the stack? > 2) are `MACRO:`s allowed to have invalid stack effect declaration? Are > they somehow exempted from the compiler checks? > > I'm asking this because the declared stack effect shows up in the > documentation, and is confusing. Reading it gives the expression that it > should be used with an extra `call` to the produced quotation: > `11 "he%do, world" printf call` > > 18.01.2018, 19:00, "John Benediktsson" : > > Both of those are macros (basically special words that produce a > quotation), so when "called" they are first macro-expanded into a quotation > and then that quotation is called, with whatever stack effect it has. > > IN: scratchpad 1 2 3 "%s %s %s" printf > 1 2 3 > > IN: scratchpad [ "%s %s %s" printf ] infer > ( x x x -- ) > > IN: scratchpad [ "%s %s %s" printf ] expand-macros > [ > [ present ] 2 ndip [ " " ] 2 ndip [ present ] 1 ndip > [ " " ] 1 ndip [ present ] 0 ndip output-stream get > [ stream-write ] curry 5 napply > ] > > Maybe the article I wrote when developing it would help: > > https://re-factor.blogspot.com/2011/08/printf.html > > > On Thu, Jan 18, 2018 at 4:32 AM, Alexander Ilin wrote: > > Hello! > > There are two similar words: printf and sprintf. They have similar stack > effects, but different behavior. > > MACRO: sprintf ( format-string -- result ) > leaves a string on stack > > MACRO: printf ( format-string -- quot ) > leaves nothing on stack despite the stack effect specified > > How come `printf` does'n obey its declared stack effect? > > ---=--- > Александр > > > > ---=--- > Александр > > > -- > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > ___ > Factor-talk mailing list > Factor-talk@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/factor-talk > > , > > > -- > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > > , > > ___ > Factor-talk mailing list > Factor-talk@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/factor-talk > > > > ---=--- > Александр > > > -- > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > ___ > Factor-talk mailing list > Factor-talk@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/factor-talk > -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slash
Re: [Factor-talk] printf documentation
Can I simply change the stack effects for the purposes of documenting them like this?```MACRO: printf ( ... string -- )MACRO: sprintf ( ... string -- result )``` 18.01.2018, 23:44, "Doug Coleman" :Stack effects on macros are not checked. We have the convention of lying that the stack effect is ( input -- quot ) but even that is wrong, as the macro is called immediately so you don't get a quot on the stack. The quot could have a stack effect of its own but it's variable arity, as you are seeing with printf. If you have a way to resolve this, lemme know! (One idea is "input-only stack effects" which don't have an output, so you could do ``MACRO: printf ( string ) ... ;``) On Thu, Jan 18, 2018 at 2:36 PM Alexander Ilinwrote:O-kay... Let me try to ask my question again... I've read the blog post that you linked to. In there I found the following declaration:`MACRO: printf ( format-string -- )` This means that the macro takes one argument and removes it from the stack, doesn't put anything back. But in the actual source code of the `formatting` vocab the declaration is: `MACRO: printf ( format-string -- quot )`, which looks as if the `printf` word takes one parameter off the stack and puts one item back on the stack. ... which is not true: it doesn't put a quotation on the stack, because it calls the quotation. So, I have two questions, basically: 1) why not change the declaration in `formatting` to ``MACRO: printf ( format-string -- )` - with no output onto the stack?2) are `MACRO:`s allowed to have invalid stack effect declaration? Are they somehow exempted from the compiler checks? I'm asking this because the declared stack effect shows up in the documentation, and is confusing. Reading it gives the _expression_ that it should be used with an extra `call` to the produced quotation:`11 "he%do, world" printf call` 18.01.2018, 19:00, "John Benediktsson" :Both of those are macros (basically special words that produce a quotation), so when "called" they are first macro-expanded into a quotation and then that quotation is called, with whatever stack effect it has. IN: scratchpad 1 2 3 "%s %s %s" printf1 2 3 IN: scratchpad [ "%s %s %s" printf ] infer( x x x -- ) IN: scratchpad [ "%s %s %s" printf ] expand-macros[ [ present ] 2 ndip [ " " ] 2 ndip [ present ] 1 ndip [ " " ] 1 ndip [ present ] 0 ndip output-stream get [ stream-write ] curry 5 napply] Maybe the article I wrote when developing it would help: https://re-factor.blogspot.com/2011/08/printf.html On Thu, Jan 18, 2018 at 4:32 AM, Alexander Ilin wrote:Hello! There are two similar words: printf and sprintf. They have similar stack effects, but different behavior.MACRO: sprintf ( format-string -- result )leaves a string on stackMACRO: printf ( format-string -- quot )leaves nothing on stack despite the stack effect specified How come `printf` does'n obey its declared stack effect?---=--- Александр ---=---Александр --Check out the vibrant tech community on one of the world's mostengaging tech sites, Slashdot.org! http://sdm.link/slashdot___Factor-talk mailing listFactor-talk@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/factor-talk,--Check out the vibrant tech community on one of the world's mostengaging tech sites, Slashdot.org! http://sdm.link/slashdot,___Factor-talk mailing listFactor-talk@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/factor-talk ---=---Александр -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] printf documentation
Stack effects on macros are not checked. We have the convention of lying that the stack effect is ( input -- quot ) but even that is wrong, as the macro is called immediately so you don't get a quot on the stack. The quot could have a stack effect of its own but it's variable arity, as you are seeing with printf. If you have a way to resolve this, lemme know! (One idea is "input-only stack effects" which don't have an output, so you could do ``MACRO: printf ( string ) ... ;``) On Thu, Jan 18, 2018 at 2:36 PM Alexander Ilin wrote: > O-kay... Let me try to ask my question again... > > I've read the blog post that you linked to. In there I found the following > declaration: > `*MACRO:* printf ( format-string -- )` > > This means that the macro takes one argument and removes it from the > stack, doesn't put anything back. > > But in the actual source code of the `formatting` vocab the declaration > is: `MACRO: printf ( format-string -- quot )`, which looks as if the > `printf` word takes one parameter off the stack and puts one item back on > the stack. > > ... which is not true: it doesn't put a quotation on the stack, because it > calls the quotation. > > So, I have two questions, basically: > > 1) why not change the declaration in `formatting` to ``MACRO: printf ( > format-string -- )` - with no output onto the stack? > 2) are `MACRO:`s allowed to have invalid stack effect declaration? Are > they somehow exempted from the compiler checks? > > I'm asking this because the declared stack effect shows up in the > documentation, and is confusing. Reading it gives the expression that it > should be used with an extra `call` to the produced quotation: > `11 "he%do, world" printf call` > > 18.01.2018, 19:00, "John Benediktsson" : > > Both of those are macros (basically special words that produce a > quotation), so when "called" they are first macro-expanded into a quotation > and then that quotation is called, with whatever stack effect it has. > > IN: scratchpad 1 2 3 "%s %s %s" printf > 1 2 3 > > IN: scratchpad [ "%s %s %s" printf ] infer > ( x x x -- ) > > IN: scratchpad [ "%s %s %s" printf ] expand-macros > [ > [ present ] 2 ndip [ " " ] 2 ndip [ present ] 1 ndip > [ " " ] 1 ndip [ present ] 0 ndip output-stream get > [ stream-write ] curry 5 napply > ] > > Maybe the article I wrote when developing it would help: > > https://re-factor.blogspot.com/2011/08/printf.html > > > On Thu, Jan 18, 2018 at 4:32 AM, Alexander Ilin wrote: > > Hello! > > There are two similar words: printf and sprintf. They have similar stack > effects, but different behavior. > > MACRO: sprintf ( format-string -- result ) > leaves a string on stack > > MACRO: printf ( format-string -- quot ) > leaves nothing on stack despite the stack effect specified > > How come `printf` does'n obey its declared stack effect? > > ---=--- > Александр > > > > ---=--- > Александр > > > -- > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > ___ > Factor-talk mailing list > Factor-talk@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/factor-talk > -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] printf documentation
O-kay... Let me try to ask my question again... I've read the blog post that you linked to. In there I found the following declaration:`MACRO: printf ( format-string -- )` This means that the macro takes one argument and removes it from the stack, doesn't put anything back. But in the actual source code of the `formatting` vocab the declaration is: `MACRO: printf ( format-string -- quot )`, which looks as if the `printf` word takes one parameter off the stack and puts one item back on the stack. ... which is not true: it doesn't put a quotation on the stack, because it calls the quotation. So, I have two questions, basically: 1) why not change the declaration in `formatting` to ``MACRO: printf ( format-string -- )` - with no output onto the stack?2) are `MACRO:`s allowed to have invalid stack effect declaration? Are they somehow exempted from the compiler checks? I'm asking this because the declared stack effect shows up in the documentation, and is confusing. Reading it gives the _expression_ that it should be used with an extra `call` to the produced quotation:`11 "he%do, world" printf call` 18.01.2018, 19:00, "John Benediktsson" :Both of those are macros (basically special words that produce a quotation), so when "called" they are first macro-expanded into a quotation and then that quotation is called, with whatever stack effect it has. IN: scratchpad 1 2 3 "%s %s %s" printf1 2 3 IN: scratchpad [ "%s %s %s" printf ] infer( x x x -- ) IN: scratchpad [ "%s %s %s" printf ] expand-macros[ [ present ] 2 ndip [ " " ] 2 ndip [ present ] 1 ndip [ " " ] 1 ndip [ present ] 0 ndip output-stream get [ stream-write ] curry 5 napply] Maybe the article I wrote when developing it would help: https://re-factor.blogspot.com/2011/08/printf.html On Thu, Jan 18, 2018 at 4:32 AM, Alexander Ilinwrote:Hello! There are two similar words: printf and sprintf. They have similar stack effects, but different behavior.MACRO: sprintf ( format-string -- result )leaves a string on stackMACRO: printf ( format-string -- quot )leaves nothing on stack despite the stack effect specified How come `printf` does'n obey its declared stack effect?---=--- Александр ---=---Александр -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
[Factor-talk] FP Meetup organizer in Toronto seeking a speaker
Hi, I'm an organizer of a functional programming meetup group in Toronto [1]. I'm also interested in introducing myself and other members to languages like Factor. I was wondering if there were any Factor users in the Toronto area who would like to give a talk about Factor. We are a meetup group of 5 to 12 people so it's a small group. If anyone is interested, please do let me know. Please continue the good work! [1] - https://www.meetup.com/FunctionalTO-meetup/ -- Take care, Rajiv -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] printf documentation
Both of those are macros (basically special words that produce a quotation), so when "called" they are first macro-expanded into a quotation and then that quotation is called, with whatever stack effect it has. IN: scratchpad 1 2 3 "%s %s %s" printf 1 2 3 IN: scratchpad [ "%s %s %s" printf ] infer ( x x x -- ) IN: scratchpad [ "%s %s %s" printf ] expand-macros [ [ present ] 2 ndip [ " " ] 2 ndip [ present ] 1 ndip [ " " ] 1 ndip [ present ] 0 ndip output-stream get [ stream-write ] curry 5 napply ] Maybe the article I wrote when developing it would help: https://re-factor.blogspot.com/2011/08/printf.html On Thu, Jan 18, 2018 at 4:32 AM, Alexander Ilin wrote: > Hello! > > There are two similar words: printf and sprintf. They have similar stack > effects, but different behavior. > > MACRO: sprintf ( format-string -- result ) > leaves a string on stack > > MACRO: printf ( format-string -- quot ) > leaves nothing on stack despite the stack effect specified > > How come `printf` does'n obey its declared stack effect? > > ---=--- > Александр > > > > -- > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > ___ > Factor-talk mailing list > Factor-talk@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/factor-talk > -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
[Factor-talk] printf documentation
Hello! There are two similar words: printf and sprintf. They have similar stack effects, but different behavior. MACRO: sprintf ( format-string -- result ) leaves a string on stack MACRO: printf ( format-string -- quot ) leaves nothing on stack despite the stack effect specified How come `printf` does'n obey its declared stack effect? ---=--- Александр -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk