Puzzled about handlers with labeled parameters

Hello, I’m picking up AppleScript and have a problem of understaning some how AppleScript copes with handles with labeled paramters.

Consider the following script


set myName to "Agnar Renolen"
set wifeName to replace of myName into "Jana" instead of "Agnar"
set authorName to replace of myName into "Mykle" instead of "Renolen"
set aFarmer to replace of myName into "rari" instead of "nar Renol"
set stillMyName to replace of myName into "Blabla" instead of "Blabla"

to replace of aString into newStr instead of subStr
	set iStart to offset of subStr in aString
	if iStart is 0 then
		return aString
	end if
	set iEnd to iStart + (length of subStr)
	if iStart is 1 then
		set str1 to ""
	else
		set str1 to (text from character 1 to character (iStart - 1) of aString)
	end if
	
	set iLast to count characters in aString
	if iEnd is greater than iLast then
		set str2 to ""
	else
		set str2 to (text from character iEnd to character iLast of aString)
	end if
	
	return str1 & newStr & str2
end replace

This script works as intended. But:

1)Why can’t I replace “of” with “from” in the handler declaration, i.e:

to replace from aString into newStr instead of subStr

This generates a compiler error.

2) How can I call this handler from within a tell block. I can’t find a syntax that works?
(It works if I redeclare the handler to have positional parameters)

This compiles fine here:

to replace from aString into newStr instead of subStr
	"blah"
end replace

Anyway, the AppleScript Language Guide seems to state that you must use “in” or “of” in the first labeled parameter, called “direct parameter variable”, kind of fake of the structure in scripting additions or scriptable applications’ commands. (pag. 290).

You usually call handlers from within tell blocks using “my” or “of me”. If you already use this method, perhaps the related application defines some of your prepositions in some part of its own dictionary, and that’s why it’s conflicting (it maybe calling an application class instead of a plain applescript label).

Defining a Subroutine With Labeled Parameters