Re: Rules for method resolution?

2004-02-15 Thread Michal Wallace
On Sun, 15 Feb 2004, Luke Palmer wrote:

 As with Perl 6.  A sub object has a Cdo trait which specifies what
 to do when it's called.

Cool.

 But I think findmethod is a good idea, cross-language-wise.  Each
 language has a different idea of what a method is, and they can
 store it that way.  As long as findmethod is vtableable, you can
 hook it up to whatever system your language uses.

I was thinking the same thing as I wrote my post
last night... But I'm not convinced.
Suppose I do something like this:

  x = parrot.find(perl::whatever)
  x.method()

Is that second line a method call or a function call?
It depends whether x is an object or not. Now maybe
in SOME cases (no dynamic input) a compiler could be
smart enough to tell for python... But how could I
ever know cross language?

How will the compiler know to emit findmethod here
rather than getproperty?

I would suggest that since perl and python both
work this way, this is the way it should work
for parrot.

If a language happens to let you do something like:

class MultiAttribute {
x : int = 2;
method x() {
  return 1;
}
}

Then getattr(x) should return some kind of smart
attribute that knows how to evaluate to 2 if it's
used as an int or 5 if it's called.

And what about this?

class MultiMethod {
   method x(a:int) { return a+1; }
   method x(a:str) { return 200; }
}


Which x does the get? or does my compiler have to be
smart enough to look at the arguments that get passed
in? I submit that's impossible to determine, too:


args = input(enter arguments)
foo.multimethod(*args)


I think all methods for all languages should act the
perl/python way for this reason. Or at least all
languages that want to talk to each other should
emit getprop (or something like it) and then if the
property is invoked, it should be called just like a
normal function. If it needs a magic self variable
or does some kind of dispatch based on the arguments,
then that should be handled internally by the method
PMC.

In fact, since I'm on the subject, properties and
attributes also have this problem. If we want our
languages to work together there should be one and
only one type of slot on an object.  It should
be up to the PMC itself to determine how that
works internally. If a more static language has
objects that are all the same size and wants attributes
instead of properties then it should handle that
internally. The interface should be the same either way.

Sincerely,

Michal J Wallace
Sabren Enterprises, Inc.
-
contact: [EMAIL PROTECTED]
hosting: http://www.cornerhost.com/
my site: http://www.withoutane.com/
-


Re: JIT branches under the Sun

2004-02-15 Thread Stephane Peiry
On Sat, Feb 14, 2004 at 06:19:42PM +0100, Leopold Toetsch wrote:
 If that runs and it works you get a stabs file (for parrot -d -j). This is
 compiled via an hardcoded line with as. s. jit_debug.c

mh ok, I do get the stabs file,  and apparently the reason no objfile gets
created is that as complains with loads of warnings and some errors when
given the stab file.

Attached is an example stab file generated for a very simple pasm, and the
warnings/errors as complains about when feeded with it..  mainly hopping
that you can spot the problem? :)

 leo

Thanks,
Stéphane
set I1, 333
end
.stabs set.pasm,100,0,0,0
.stabs jit_func:F(0,1),36,0,1,267f10
.stabs Void:t(0,0)=(0,1),128,0,0,0
.stabs Char:t(0,1)=r(0,1);-128;127;,128,0,0,0
.stabs Byte:t(0,2)=r(0,2);0;255;,128,0,0,0
.stabs Int16:t(0,3)=r(0,3);-32768;32767;,128,0,0,0
.stabs UInt16:t(0,4)=r(0,4);0;65535;,128,0,0,0
.stabs Int32:t(0,5)=r(0,5);00200;00177;,128,0,0,0
.stabs UInt32:t(0,6)=r(0,6);0;00377;,128,0,0,0
.stabs Int64:t(0,7)=r(0,7);010;07;,128,0,0,0
.stabs UInt64:t(0,8)=r(0,8);0;017;,128,0,0,0
.stabs Single:t(0,9)=r(0,8);4;0;,128,0,0,0
.stabs Double:t(0,10)=r(0,8);8;0;,128,0,0,0
.stabs LongDouble:t(0,11)=r(0,8);12;0;,128,0,0,0
.stabs INTVAL:t(0,12)=(0,5);,128,0,0,0
.stabs FLOATVAL:t(0,13)=(0,10);,128,0,0,0
.stabs Ptr:t(0,14)=*(0,0);,128,0,0,0
.stabs CharPtr:t(0,15)=*(0,1);,128,0,0,0
.stabs STRING:t(0,16)=*(0,17),128,0,0,0
.stabs 
Parrot_String:T(0,17)=s40bufstart:(0,14),0,32;buflen:(0,6),32,32;flags:(0,12),64,32;bufused:(0,12),128,32;strstart:(0,15),160,32;;,128,0,0,0
.stabs 
PMCType:T(0,18)=eArray:1,Boolean:2,Closure:3,Compiler:4,Continuation:5,Coroutine:6,CSub:7,delegate:8,Env:9,Eval:10,Exception:11,Exception_Handler:12,Float:13,Integer:14,IntList:15,Iterator:16,Key:17,ManagedStruct:18,mmd_default:19,MultiArray:20,NCI:21,Null:22,OrderedHash:23,ParrotClass:24,ParrotInterpreter:25,ParrotIO:26,ParrotLibrary:27,ConstParrotLibrary:28,ParrotObject:29,ParrotThread:30,PerlArray:31,PerlEnv:32,PerlHash:33,PerlInt:34,PerlNum:35,PerlString:36,PerlUndef:37,Pointer:38,Random:39,Ref:40,RetContinuation:41,SArray:42,ConstSArray:43,Scratchpad:44,SharedRef:45,Sub:46,Timer:47,TQueue:48,UnManagedStruct:49,Version:50,;,128,0,0,0
.stabs 
PMC:T(0,19)=s24obj:(0,20),0,128;vtable:*(0,22),128,32;pmc_ext:*(0,19),160,32;;,128,0,0,0
.stabs pobj_t:T(0,20)=s16u:(0,21),0,64;flags:(0,12),64,32;;,128,0,0,0
.stabs UnionVal:T(0,21)=u8int_val:(0,12),0,32;pmc_val:*(0,19),32,32;;,128,0,0,0
.stabs VTABLE:T(0,22)=s8base_type:(0,18),32,32;;,128,0,0,0
.stabs I0:S(0,12),38,0,0,222590
.stabs N0:S(0,13),38,0,0,222610
.stabs S0:S(0,16),38,0,0,222710
.stabs P0:S*(0,19),38,0,0,222790
.stabs I1:S(0,12),38,0,0,222594
.stabs N1:S(0,13),38,0,0,222618
.stabs S1:S(0,16),38,0,0,222714
.stabs P1:S*(0,19),38,0,0,222794
.stabs I2:S(0,12),38,0,0,222598
.stabs N2:S(0,13),38,0,0,222620
.stabs S2:S(0,16),38,0,0,222718
.stabs P2:S*(0,19),38,0,0,222798
.stabs I3:S(0,12),38,0,0,22259c
.stabs N3:S(0,13),38,0,0,222628
.stabs S3:S(0,16),38,0,0,22271c
.stabs P3:S*(0,19),38,0,0,22279c
.stabs I4:S(0,12),38,0,0,2225a0
.stabs N4:S(0,13),38,0,0,222630
.stabs S4:S(0,16),38,0,0,222720
.stabs P4:S*(0,19),38,0,0,2227a0
.stabs I5:S(0,12),38,0,0,2225a4
.stabs N5:S(0,13),38,0,0,222638
.stabs S5:S(0,16),38,0,0,222724
.stabs P5:S*(0,19),38,0,0,2227a4
.stabs I6:S(0,12),38,0,0,2225a8
.stabs N6:S(0,13),38,0,0,222640
.stabs S6:S(0,16),38,0,0,222728
.stabs P6:S*(0,19),38,0,0,2227a8
.stabs I7:S(0,12),38,0,0,2225ac
.stabs N7:S(0,13),38,0,0,222648
.stabs S7:S(0,16),38,0,0,22272c
.stabs P7:S*(0,19),38,0,0,2227ac
.stabs I8:S(0,12),38,0,0,2225b0
.stabs N8:S(0,13),38,0,0,222650
.stabs S8:S(0,16),38,0,0,222730
.stabs P8:S*(0,19),38,0,0,2227b0
.stabs I9:S(0,12),38,0,0,2225b4
.stabs N9:S(0,13),38,0,0,222658
.stabs S9:S(0,16),38,0,0,222734
.stabs P9:S*(0,19),38,0,0,2227b4
.stabs I10:S(0,12),38,0,0,2225b8
.stabs N10:S(0,13),38,0,0,222660
.stabs S10:S(0,16),38,0,0,222738
.stabs P10:S*(0,19),38,0,0,2227b8
.stabs I11:S(0,12),38,0,0,2225bc
.stabs N11:S(0,13),38,0,0,222668
.stabs S11:S(0,16),38,0,0,22273c
.stabs P11:S*(0,19),38,0,0,2227bc
.stabs I12:S(0,12),38,0,0,2225c0
.stabs N12:S(0,13),38,0,0,222670
.stabs S12:S(0,16),38,0,0,222740
.stabs P12:S*(0,19),38,0,0,2227c0
.stabs I13:S(0,12),38,0,0,2225c4
.stabs N13:S(0,13),38,0,0,222678
.stabs S13:S(0,16),38,0,0,222744
.stabs P13:S*(0,19),38,0,0,2227c4
.stabs I14:S(0,12),38,0,0,2225c8
.stabs N14:S(0,13),38,0,0,222680
.stabs S14:S(0,16),38,0,0,222748
.stabs P14:S*(0,19),38,0,0,2227c8
.stabs I15:S(0,12),38,0,0,2225cc
.stabs N15:S(0,13),38,0,0,222688
.stabs S15:S(0,16),38,0,0,22274c
.stabs P15:S*(0,19),38,0,0,2227cc
.stabs I16:S(0,12),38,0,0,2225d0
.stabs N16:S(0,13),38,0,0,222690
.stabs S16:S(0,16),38,0,0,222750
.stabs P16:S*(0,19),38,0,0,2227d0
.stabs I17:S(0,12),38,0,0,2225d4
.stabs N17:S(0,13),38,0,0,222698
.stabs S17:S(0,16),38,0,0,222754
.stabs P17:S*(0,19),38,0,0,2227d4
.stabs