[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Interfacing to AppleEvents



At 12.44 97/6/15, Michael Schuerig wrote:
>>1.)  A fundamental problem with AppleScript is its syntax.  Why continue to
>>use it?
>
>AppleScript is approachable by end-users. They can start recording
>something and then adapt it. I very much doubt those people would ever dare
>to put their hands on perl. Probably you don't care about this, it's a
>position that can well be argued for. I do care about a simple scripting
>language.

I was speaking from a perspective of using AS from Perl, not from using AS
at all.  As far as using AS from Perl, the syntax is horrible.  For some
people, it works.  But from Perl, there should be a better way.

And as I have said repeatedly, I don't want to force anyone to give up
AppleScript.  I personally dislike AS, but if you want to use it, I won't
stop you.  What I want it to give people alternatives to AS and
MacPerl::DoAppleScript.


>OTOH, I wouldn't even try to built object specifiers in perl. In AS it's as
>easy as it can get: "set style of first line of first paragraph to bold";
>or "set style of first word of every paragraph to bold" (this won't work
>for most scriptable apps, but it's not AS's fault!).

AE('app','set',{style=>{bold=>['pargraph','first',['line','first']]}});

I am thinking along these lines.  Maybe something better could be drummed
up, something with a better OO syntax.  But certainly doable, and
certainly, IMO, nicer for Perl-type persons after the syntax is all hashed
out (no pun intended :-).


>>4.)  AppleScript from MacPerl will alwyas be slower than AEs straight from
>>MacPerl, because AppleScript has to be compiled first.  It takes an extra
>>step.
>
>To the contrary. Perl has to compile the script *every time* it's going to
>be executed (and it does this amazingly fast, of course). AS only compiles
>scripts once. Have a look into a 'scpt' resource, it contains some sort of
>AS bytecode. The compilation takes time and quite some in the current
>implementation, so turnaround time in AS is longer.

No.  I think you misunderstand what I said.  I did not say Perl is faster
than AppleScript, I said AppleScript FROM Perl is slower than AppleEvents
from Perl.  Yes, AppleScript (for now) is probably faster with AEs for the
reason you mention.  But just as MacPerl has to be compiled each time, an
AppleScript embedded in Perl has to be compiled each time.

--
Chris Nandor                 pudge@pobox.com                 http://pudge.net/
%PGPKey=('B76E72AD',[1024,'08 24 09 0B CE 73 CA 10  1F F7 7F 13 81 80 B6 B6'])



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch