Need help converting monkey 1 to monkey 2 code.

About Monkey 2 Forums Monkey 2 Programming Help Need help converting monkey 1 to monkey 2 code.

This topic contains 10 replies, has 3 voices, and was last updated by  Jesse 2 years, 10 months ago.

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #1423

    Jesse
    Participant

    I am trying to convert this code to monkey 2 but I can’t figure out how to do it correctly it works in monkey 1:

    [/crayon]

     

    I get this errors trying to compile it:

    /Users/legend/Desktop/patrol 2/store.monkey2 [32] : Error : Identifier ‘T’ not found
    /Users/legend/Desktop/patrol 2/store.monkey2 [38] : Error : Can’t find overload for ‘new(…)’ with argument types ()
    /Users/legend/Desktop/patrol 2/store.monkey2 [29] : Error : Missing return statement
    /Users/legend/Desktop/patrol 2/store.monkey2 [18] : Error : Can’t find overload for ‘new(…)’ with argument types ()
    /Users/legend/Desktop/patrol 2/store.monkey2 [19] : Error : Identifier ‘c’ not found
    /Users/legend/Desktop/patrol 2/store.monkey2 [20] : Error : Identifier ‘c’ not found
    //Users/legend/Desktop/patrol 2/store.monkey2 [9] : Error : Missing return statement
    /Users/legend/Desktop/patrol 2/store.monkey2 [32] : Error : Identifier ‘T’ not found
    /Users/legend/Desktop/patrol 2/store.monkey2 [38] : Error : Can’t find overload for ‘new(…)’ with argument types ()
    /Users/legend/Desktop/patrol 2/store.monkey2 [29] : Error : Missing return statement
    /Users/legend/Desktop/patrol 2/store.monkey2 [18] : Error : Can’t find overload for ‘new(…)’ with argument types ()
    /Users/legend/Desktop/patrol 2/store.monkey2 [19] : Error : Identifier ‘c’ not found
    /Users/legend/Desktop/patrol 2/store.monkey2 [20] : Error : Identifier ‘c’ not found

     

     

    still trying to figure out how to post code here.

    #1439

    peterigz
    Participant

    Are you wanting T to be a generic type? I think you’re just missing the <T> after the class declaration..

    #1442

    Jesse
    Participant

    I don’t know how that got removed.  I do have it on my original code. apparently in the process of figuring out how to post code here it got removed. So the error happen with the “<T>” in place.

    #1447

    impixi
    Participant

    Explicit casting in MX2 is different than MX1. This line:

    last = T(last._pred)

    Should be:

    last = Cast<T>(last._pred)

    The following should compile without errors (I haven’t checked for any logic errors though):

    [/crayon]
    #1450

    Jesse
    Participant

    thanks Impixi. I was wondering about the casting thing. that solved several errors. but I still get these errors (on my code):

    /Users/legend/Desktop/patrol 2/store.monkey2 [38] : Error : Can’t find overload for ‘new(…)’ with argument types ()
    /Users/legend/Desktop/patrol 2/store.monkey2 [29] : Error : Missing return statement
    /Users/legend/Desktop/patrol 2/store.monkey2 [18] : Error : Can’t find overload for ‘new(…)’ with argument types ()
    /Users/legend/Desktop/patrol 2/store.monkey2 [19] : Error : Identifier ‘c’ not found
    /Users/legend/Desktop/patrol 2/store.monkey2 [20] : Error : Identifier ‘c’ not found

    #1452

    impixi
    Participant

    What’s your code for creating a new Store instance?

    #1454

    Jesse
    Participant

    it uses this as a base for all my objects:

    I create instance of it the same way you did in your example. it works fine in monkey1 but I can’t figure this errors out.

    #1476

    impixi
    Participant

    If you’re making use of inheritance there are issues relating to constructor “chaining” – might be related to your errors?

    There’s a forum topic about it:
    http://monkey2.monkey-x.com/forums/topic/referencing-new/

    You might need to rework your underlying architecture a little bit to make it play nice with MX2…

    #1479

    Jesse
    Participant

    I don’t think that’s the issue. the problem seems to be when creating an instance of generic such as:

    </p><p>new T().</p><p>

    #1481

    Jesse
    Participant

    well I isolated the code and it seems to work fine. it has to be from other files that are accessing it.

     

    Thanks Impixi for your help.

    #1790

    Jesse
    Participant

    Well, I kept getting an error when create stores of new classes and I couldn’t figure out what the problem was until now. it appears that I have to create a simple new method on the “T” class or it fails to compile. I am posting this for anybody that runs into this problem.

Viewing 11 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.