macro syntax documentation?

View: New views
12 Messages — Rating Filter:   Alert me  

macro syntax documentation?

by horace3d@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


hi,

i am new to boo. i really like it (i come from python) but
documentation seems to be a bit sparse in some areas.

i wasn't able to get my own macros to work. for example:


import Boo.Lang.Compiler
macro test:
        args = property.Arguments
        return [|
                print $(args[0])
        |]
test haha


i get the error message:
internal macro could not be compiled. errors were reported.

and somehow it also seems to affect my imports because once i have
this macro in my code i get some namespace not found errors too.

what am i doing wrong? where can i find some documentation about using
macros and the macro syntax?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: macro syntax documentation?

by Cedric Vivier :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hey!

Which version of Boo are you using?
Please post all the error message(s), not only "errors were reported." ;-)

Cheers,

On Fri, Sep 4, 2009 at 10:12 AM, horace3d@... <horace3d@...> wrote:

hi,

i am new to boo. i really like it (i come from python) but
documentation seems to be a bit sparse in some areas.

i wasn't able to get my own macros to work. for example:


import Boo.Lang.Compiler
macro test:
       args = property.Arguments
       return [|
               print $(args[0])
       |]
test haha


i get the error message:
internal macro could not be compiled. errors were reported.

and somehow it also seems to affect my imports because once i have
this macro in my code i get some namespace not found errors too.

what am i doing wrong? where can i find some documentation about using
macros and the macro syntax?




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: macro syntax documentation?

by horace3d@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



On Fri, Sep 4, 2009 at 4:51 AM, Cedric Vivier <cedricv@...> wrote:
Hey!

Which version of Boo are you using?

i use sharpdevelop 3.1 RC1. i am not sure what boo version is included?

Please post all the error message(s), not only "errors were reported." ;-)

Internal macro 'TestMacro' could not be compiled. Errors were reported. (BCE0039) - E:\programming\boo\test\test\Program.boo:20

Namespace 'Empty1' not found, maybe you forgot to add an assembly reference? (BCE0021) - E:\programming\boo\test\test\Program.boo:4,8



like i mentioned the namespace error also seems to get caused by the macro somehow because if i comment out the macro the import works fine.

cheers,
horace




Cheers,


On Fri, Sep 4, 2009 at 10:12 AM, horace3d@... <horace3d@...> wrote:

hi,

i am new to boo. i really like it (i come from python) but
documentation seems to be a bit sparse in some areas.

i wasn't able to get my own macros to work. for example:


import Boo.Lang.Compiler
macro test:
       args = property.Arguments
       return [|
               print $(args[0])
       |]
test haha


i get the error message:
internal macro could not be compiled. errors were reported.

and somehow it also seems to affect my imports because once i have
this macro in my code i get some namespace not found errors too.

what am i doing wrong? where can i find some documentation about using
macros and the macro syntax?







--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: macro syntax documentation?

by Cedric Vivier :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Sep 4, 2009 at 11:12 AM, horace <horace3d@...> wrote:
i use sharpdevelop 3.1 RC1. i am not sure what boo version is included?


0.9.1, RC2 will be using 0.9.2

 
Namespace 'Empty1' not found, maybe you forgot to add an assembly reference? (BCE0021) - E:\programming\boo\test\test\Program.boo:4,8

Hmm, can you post the actual code generating this error, I guess it is not the one you posted (no "Empty1").


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: macro syntax documentation?

by horace3d@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



On Fri, Sep 4, 2009 at 5:18 AM, Cedric Vivier <cedricv@...> wrote:
On Fri, Sep 4, 2009 at 11:12 AM, horace <horace3d@...> wrote:
i use sharpdevelop 3.1 RC1. i am not sure what boo version is included?


0.9.1, RC2 will be using 0.9.2

 
Namespace 'Empty1' not found, maybe you forgot to add an assembly reference? (BCE0021) - E:\programming\boo\test\test\Program.boo:4,8

Hmm, can you post the actual code generating this error, I guess it is not the one you posted (no "Empty1").



Program.boo:



import System
import Empty1

import Boo.Lang.Compiler

#macro test:
#    args = test.Arguments
#    return [|
#        Console.WriteLine($(args[0]))
#    |]

print "Hello, World!"
testfunction()

#test haha

// TODO: Implement Functionality Here

print "Press any key to continue . . . "
Console.ReadKey(true)



Empty1.boo:



namespace Empty1

def testfunction():
    print "it works!"








--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: macro syntax documentation?

by Jeffery Olson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


using the MacroStatement for the macro is going to have the name of
the macro, itself, when using the 'macro' macro.. confusing, i know..

considering the following

import Boo.Lang.Compiler
macro test:
       args = test.Arguments // 'test' is the MacroStatement
       return [|
               print $(args[0])
       |]
test haha

does that work for you?

Cheers

On Thu, Sep 3, 2009 at 8:25 PM, horace<horace3d@...> wrote:

>
>
> On Fri, Sep 4, 2009 at 5:18 AM, Cedric Vivier <cedricv@...> wrote:
>>
>> On Fri, Sep 4, 2009 at 11:12 AM, horace <horace3d@...> wrote:
>>>
>>> i use sharpdevelop 3.1 RC1. i am not sure what boo version is included?
>>>
>>
>> 0.9.1, RC2 will be using 0.9.2
>>
>>
>>>
>>> Namespace 'Empty1' not found, maybe you forgot to add an assembly
>>> reference? (BCE0021) - E:\programming\boo\test\test\Program.boo:4,8
>>
>> Hmm, can you post the actual code generating this error, I guess it is not
>> the one you posted (no "Empty1").
>
>
>
> Program.boo:
>
>
>
> import System
> import Empty1
>
> import Boo.Lang.Compiler
>
> #macro test:
> #    args = test.Arguments
> #    return [|
> #        Console.WriteLine($(args[0]))
> #    |]
>
> print "Hello, World!"
> testfunction()
>
> #test haha
>
> // TODO: Implement Functionality Here
>
> print "Press any key to continue . . . "
> Console.ReadKey(true)
>
>
>
> Empty1.boo:
>
>
>
> namespace Empty1
>
> def testfunction():
>     print "it works!"
>
>
>
>>
>>
>>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: macro syntax documentation?

by Jeffery Olson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


heh. guess i shoulda read the whole thread before replying. bleh.

On Thu, Sep 3, 2009 at 8:58 PM, Jeffery Olson<olson.jeffery@...> wrote:

> using the MacroStatement for the macro is going to have the name of
> the macro, itself, when using the 'macro' macro.. confusing, i know..
>
> considering the following
>
> import Boo.Lang.Compiler
> macro test:
>       args = test.Arguments // 'test' is the MacroStatement
>       return [|
>               print $(args[0])
>       |]
> test haha
>
> does that work for you?
>
> Cheers
>
> On Thu, Sep 3, 2009 at 8:25 PM, horace<horace3d@...> wrote:
>>
>>
>> On Fri, Sep 4, 2009 at 5:18 AM, Cedric Vivier <cedricv@...> wrote:
>>>
>>> On Fri, Sep 4, 2009 at 11:12 AM, horace <horace3d@...> wrote:
>>>>
>>>> i use sharpdevelop 3.1 RC1. i am not sure what boo version is included?
>>>>
>>>
>>> 0.9.1, RC2 will be using 0.9.2
>>>
>>>
>>>>
>>>> Namespace 'Empty1' not found, maybe you forgot to add an assembly
>>>> reference? (BCE0021) - E:\programming\boo\test\test\Program.boo:4,8
>>>
>>> Hmm, can you post the actual code generating this error, I guess it is not
>>> the one you posted (no "Empty1").
>>
>>
>>
>> Program.boo:
>>
>>
>>
>> import System
>> import Empty1
>>
>> import Boo.Lang.Compiler
>>
>> #macro test:
>> #    args = test.Arguments
>> #    return [|
>> #        Console.WriteLine($(args[0]))
>> #    |]
>>
>> print "Hello, World!"
>> testfunction()
>>
>> #test haha
>>
>> // TODO: Implement Functionality Here
>>
>> print "Press any key to continue . . . "
>> Console.ReadKey(true)
>>
>>
>>
>> Empty1.boo:
>>
>>
>>
>> namespace Empty1
>>
>> def testfunction():
>>     print "it works!"
>>
>>
>>
>>>
>>>
>>>
>>
>>
>> >>
>>
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: macro syntax documentation?

by horace3d@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



On Fri, Sep 4, 2009 at 5:58 AM, Jeffery Olson <olson.jeffery@...> wrote:

using the MacroStatement for the macro is going to have the name of
the macro, itself, when using the 'macro' macro.. confusing, i know..

considering the following

import Boo.Lang.Compiler
macro test:
      args = test.Arguments // 'test' is the MacroStatement
      return [|
              print $(args[0])
      |]
test haha

does that work for you?


no, doesn't work either.

this just was a mistake in my first email (i was wildly experimenting around and copy&pasted a version with an unfinished change by mistake) but i always used the name of the macro itself in my test runs.


 

Cheers

On Thu, Sep 3, 2009 at 8:25 PM, horace<horace3d@...> wrote:
>
>
> On Fri, Sep 4, 2009 at 5:18 AM, Cedric Vivier <cedricv@...> wrote:
>>
>> On Fri, Sep 4, 2009 at 11:12 AM, horace <horace3d@...> wrote:
>>>
>>> i use sharpdevelop 3.1 RC1. i am not sure what boo version is included?
>>>
>>
>> 0.9.1, RC2 will be using 0.9.2
>>
>>
>>>
>>> Namespace 'Empty1' not found, maybe you forgot to add an assembly
>>> reference? (BCE0021) - E:\programming\boo\test\test\Program.boo:4,8
>>
>> Hmm, can you post the actual code generating this error, I guess it is not
>> the one you posted (no "Empty1").
>
>
>
> Program.boo:
>
>
>
> import System
> import Empty1
>
> import Boo.Lang.Compiler
>
> #macro test:
> #    args = test.Arguments
> #    return [|
> #        Console.WriteLine($(args[0]))
> #    |]
>
> print "Hello, World!"
> testfunction()
>
> #test haha
>
> // TODO: Implement Functionality Here
>
> print "Press any key to continue . . . "
> Console.ReadKey(true)
>
>
>
> Empty1.boo:
>
>
>
> namespace Empty1
>
> def testfunction():
>     print "it works!"
>
>
>
>>
>>
>>
>
>
> >
>




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: macro syntax documentation?

by Rodrigo B. de Oliveira :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Fri, Sep 4, 2009 at 12:25 AM, horace<horace3d@...> wrote:
>> ...
>>>
>>> Namespace 'Empty1' not found, maybe you forgot to add an assembly
>>> reference? (BCE0021) - E:\programming\boo\test\test\Program.boo:4,8
>>

In order for a macro to be applied anywhere in the same compilation
unit/assembly it's being defined on it must be compiled. The compiler
carries that out by first generating an empty module and then copying
the macro's definition and *any imports* that appear in the macro's
defining module to it.

For your specific example:

    import System
    import Empty1
    import Boo.Lang.Compiler

    macro test:
        args = test.Arguments
        return [|
            Console.WriteLine($(args[0]))
        |]

    print "Hello, World!"
    testfunction()

    test haha #macro must be compiled before it can be applied here


the compiler will generate the following module:

    import System
    import Empty1
    import Boo.Lang.Compiler

    macro test:
        args = test.Arguments
        return [|
            Console.WriteLine($(args[0]))
        |]


which will fail to compile with the message you've seen ("Namespace
'Empty1' not found").

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: macro syntax documentation?

by horace3d@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



On Fri, Sep 4, 2009 at 3:25 PM, Rodrigo B. de Oliveira <rodrigobamboo@...> wrote:

On Fri, Sep 4, 2009 at 12:25 AM, horace<horace3d@...> wrote:
>> ...
>>>
>>> Namespace 'Empty1' not found, maybe you forgot to add an assembly
>>> reference? (BCE0021) - E:\programming\boo\test\test\Program.boo:4,8
>>

In order for a macro to be applied anywhere in the same compilation
unit/assembly it's being defined on it must be compiled. The compiler
carries that out by first generating an empty module and then copying
the macro's definition and *any imports* that appear in the macro's
defining module to it.

For your specific example:

   import System
   import Empty1
   import Boo.Lang.Compiler

   macro test:
       args = test.Arguments
       return [|
           Console.WriteLine($(args[0]))
       |]

   print "Hello, World!"
   testfunction()

   test haha #macro must be compiled before it can be applied here


the compiler will generate the following module:

   import System
   import Empty1
   import Boo.Lang.Compiler

   macro test:
       args = test.Arguments
       return [|
           Console.WriteLine($(args[0]))
       |]


which will fail to compile with the message you've seen ("Namespace
'Empty1' not found").


hm... what would be the best way to structure my sharpdevelop project then? it would be great if someone could give me some tips since this .net module/assembly stuff is quite new to me. i am only used to python modules.






--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: macro syntax documentation?

by Rodrigo B. de Oliveira :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Fri, Sep 4, 2009 at 3:16 PM, horace<horace3d@...> wrote:
> ...
> hm... what would be the best way to structure my sharpdevelop project then?
> it would be great if someone could give me some tips since this .net
> module/assembly stuff is quite new to me. i am only used to python modules.
>

Either keep the macros in a separate sharpdevelop project that you
reference from other projects that use the macros OR keep each macro
in its own module.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: macro syntax documentation?

by horace3d@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



On Fri, Sep 4, 2009 at 9:05 PM, Rodrigo B. de Oliveira <rodrigobamboo@...> wrote:

On Fri, Sep 4, 2009 at 3:16 PM, horace<horace3d@...> wrote:
> ...
> hm... what would be the best way to structure my sharpdevelop project then?
> it would be great if someone could give me some tips since this .net
> module/assembly stuff is quite new to me. i am only used to python modules.
>

Either keep the macros in a separate sharpdevelop project that you
reference from other projects that use the macros OR keep each macro
in its own module.

ok, thanks! i will experiment with that...
 




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang?hl=en
-~----------~----~----~----~------~----~------~--~---