Google Groups Home
Help | Sign in
RfD: SYNONYM
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 1 - 25 of 84 - Collapse all   Newer >
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Stephen Pelc  
View profile
 More options Aug 21 2006, 11:49 am
Newsgroups: comp.lang.forth
From: stephen...@mpeforth.com (Stephen Pelc)
Date: Mon, 21 Aug 2006 15:49:32 GMT
Local: Mon, Aug 21 2006 11:49 am
Subject: RfD: SYNONYM
RfD - Synonyms
Synonym.txt
Stephen Pelc, 21 August 2006

20060821 First draft

Rationale
=========
Problem
-------
Various words have been used to gneration a new name for an
existing word. This required when porting code and when
generating application wordlists that contain a reference
to an existing word, e.g. when providing limited access
to Forth system kernel words.

Especially with native code compiling Forth systems, these
words have not provided full access to the required behaviour
which requires carnal knowledge of the underlying system, which
is one reason why SYNONYM should be standardised.

Current practice
----------------
The proposed form SYNONYM has been in use at MPE with cross
compilers and VFX Forth since 1998.

Solution
--------
Although many people have objected to parsing words, parsing
permits the host system the most flexibility in implementation
and is thus the preferred solution.

The syntax is:
  SYNONYM <newname> <oldname>
where <newname> will behave identically to <oldname>.

Note that <newname> may be the same as <oldname>.

Proposal
========
10.6.2.xxxx SYNONYM
synonym FACILITY EXT

( "<spaces>newname" "<spaces>oldname" -- )
For both strings kip leading space delimiters. Parse name
 delimited by a space. Create a new word newname whose
execution behaviour is identical to that of the existing word
oldname. Newname may be the same as oldname.

Ambiguous conditions:
  The word newname is parsed by ' or ['] or POSTPONE.
  oldname is not found.

Labelling
=========
TBD

Reference Implementation
========================
The implementation of SYNONYM requires carnal knowledge of the host
implementation, which is one reason why it should be standardised.
The implementation below is imperfect and specific to VFX Forth.

: Synonym       \ <"new-name"> <"curdef"> --
\ *G Create a new definition which redirects to an existing one.
  create immediate
    hide  ' ,  reveal
  does>
    @  state @ 0=  over immediate? or
    if  execute  else  compile,  then
;

Test Cases
==========
TBD

--
Stephen Pelc, stephen...@mpeforth.com
MicroProcessor Engineering Ltd - More Real, Less Time
133 Hill Lane, Southampton SO15 5AF, England
tel: +44 (0)23 8063 1441, fax: +44 (0)23 8033 9691
web: http://www.mpeforth.com - free VFX Forth downloads


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
George Hubert  
View profile
 More options Aug 21 2006, 12:28 pm
Newsgroups: comp.lang.forth
From: "George Hubert" <georgeahub...@yahoo.co.uk>
Date: 21 Aug 2006 09:28:16 -0700
Local: Mon, Aug 21 2006 12:28 pm
Subject: Re: RfD: SYNONYM

Win32Forth already supports SYNONYM with the same syntax.

George Hubert


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "SYNONYM" by Andreas Kochenburger
Andreas Kochenburger  
View profile
 More options Aug 21 2006, 1:45 pm
Newsgroups: comp.lang.forth
From: "Andreas Kochenburger" <a...@privat.de>
Date: Mon, 21 Aug 2006 19:45:17 +0200
Local: Mon, Aug 21 2006 1:45 pm
Subject: Re: SYNONYM

> The syntax is:
>  SYNONYM <newname> <oldname>
> where <newname> will behave identically to <oldname>.

ALIAS is used for the same purpose
' <oldname> ALIAS NEWNAME

Its syntax is similar to IS.
My personal vote is for ALIAS


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "RfD: SYNONYM" by J Thomas
J Thomas  
View profile
 More options Aug 21 2006, 1:56 pm
Newsgroups: comp.lang.forth
From: "J Thomas" <jethom...@gmail.com>
Date: 21 Aug 2006 10:56:15 -0700
Local: Mon, Aug 21 2006 1:56 pm
Subject: Re: RfD: SYNONYM

Stephen Pelc wrote:
> Especially with native code compiling Forth systems, these
> words have not provided full access to the required behaviour
> which requires carnal knowledge of the underlying system, which
> is one reason why SYNONYM should be standardised.

....

> Ambiguous conditions:
>   The word newname is parsed by ' or ['] or POSTPONE.
>   oldname is not found.

I see no particular reason not to standardise this just as you say.
It's already reasonably common practice.

As a side issue, what behavior will a portable SYNONYM written in
standard Forth fail at, that doesn't involve ' or ['] or POSTPONE ? I
haven't found anything quickly.

This is as close as I came:

SYNONYM MY-DUP DUP

SYNONYM YOUR-DUP MY-DUP

A portable SYNONYM would probably use ' or ['] or POSTPONE on MY-DUP
here and fit the ambiguous condition, but a primitive SYNONYM wouldn't
have to.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "SYNONYM" by Coos Haak
Coos Haak  
View profile
 More options Aug 21 2006, 2:05 pm
Newsgroups: comp.lang.forth
From: Coos Haak <chfo...@hccnet.nl>
Date: Mon, 21 Aug 2006 20:05:03 +0200
Local: Mon, Aug 21 2006 2:05 pm
Subject: Re: SYNONYM
Op Mon, 21 Aug 2006 19:45:17 +0200 schreef Andreas Kochenburger:

>> The syntax is:
>>  SYNONYM <newname> <oldname>
>> where <newname> will behave identically to <oldname>.

> ALIAS is used for the same purpose
> ' <oldname> ALIAS NEWNAME

> Its syntax is similar to IS.
> My personal vote is for ALIAS

I've been using this for years. Seems it is older than SYNONYM.

--
Coos

CHForth, 16 bit DOS applications
http://home.hccnet.nl/j.j.haak/forth.html


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stephen Pelc  
View profile
 More options Aug 21 2006, 2:22 pm
Newsgroups: comp.lang.forth
From: stephen...@mpeforth.com (Stephen Pelc)
Date: Mon, 21 Aug 2006 18:22:25 GMT
Local: Mon, Aug 21 2006 2:22 pm
Subject: Re: SYNONYM
On Mon, 21 Aug 2006 19:45:17 +0200, "Andreas Kochenburger"

<a...@privat.de> wrote:
>> The syntax is:
>>  SYNONYM <newname> <oldname>
>> where <newname> will behave identically to <oldname>.

>ALIAS is used for the same purpose
>' <oldname> ALIAS NEWNAME

>Its syntax is similar to IS.
>My personal vote is for ALIAS

It breaks on some systems (and they exist) that cannot get from
the xt of a word to enough needed information to create the new
word. The point of SYNONYM is that it can be as carnal as necessary.

Stephen

--
Stephen Pelc, stephen...@mpeforth.com
MicroProcessor Engineering Ltd - More Real, Less Time
133 Hill Lane, Southampton SO15 5AF, England
tel: +44 (0)23 8063 1441, fax: +44 (0)23 8033 9691
web: http://www.mpeforth.com - free VFX Forth downloads


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
pablo reda  
View profile
 More options Aug 21 2006, 8:52 pm
Newsgroups: comp.lang.forth
From: "pablo reda" <pablor...@gmail.com>
Date: 21 Aug 2006 17:52:47 -0700
Local: Mon, Aug 21 2006 8:52 pm
Subject: Re: SYNONYM
There are a complete example for know  the useful of ALIAS or something
?

I ask from ignorance but I don't think if is necessary,
I have only 1 year of forth programing..and 25 of others..


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "RfD: SYNONYM" by Ed
Ed  
View profile
 More options Aug 23 2006, 8:49 pm
Newsgroups: comp.lang.forth
From: "Ed" <nos...@invalid.com>
Date: Thu, 24 Aug 2006 10:49:51 +1000
Local: Wed, Aug 23 2006 8:49 pm
Subject: Re: RfD: SYNONYM

"George Hubert" <georgeahub...@yahoo.co.uk> wrote in message

news:1156177696.845015.227430@m73g2000cwd.googlegroups.com...

> Stephen Pelc wrote:
> > RfD - Synonyms
> > ...
> > The syntax is:
> >   SYNONYM <newname> <oldname>
> > where <newname> will behave identically to <oldname>.

> > Note that <newname> may be the same as <oldname>.

> ...
> Win32Forth already supports SYNONYM with the same syntax.

Not so fast :)

I wonder how many missed the part in the spec about making
aliases with the same name!

A conforming  SYNONYM  should be able to handle this:

    \ Test SYNONYM ability to make alias with same name
    CR
    FORTH ALSO DEFINITIONS
    : TEST  ." hello " ;
    VOCABULARY NEWVOC
    NEWVOC DEFINITIONS
    SYNONYM TEST TEST  ( make alias in new vocab )
    CR .( now testing alias ) CR
    NEWVOC  TEST


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alex McDonald  
View profile
 More options Aug 24 2006, 7:04 am
Newsgroups: comp.lang.forth
From: "Alex McDonald" <alex_...@btopenworld.com>
Date: 24 Aug 2006 04:04:05 -0700
Local: Thurs, Aug 24 2006 7:04 am
Subject: Re: RfD: SYNONYM

You're right; Win32Forth fails this test due to a timing issue creating
the dictionary entry. At the point where SYNONYM is executed, the ORDER
is

order
Context: NEWVOC FORTH FORTH ROOT
Current: NEWVOC  ok

TEST is being defined, then searched for, rather than searched for then
defined; so it finds itself rather than the TEST in the FORTH
vocabulary. WIll be corrected.

--
Regards
Alex McDonald


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
George Hubert  
View profile
 More options Aug 24 2006, 7:14 am
Newsgroups: comp.lang.forth
From: "George Hubert" <georgeahub...@yahoo.co.uk>
Date: 24 Aug 2006 04:14:45 -0700
Local: Thurs, Aug 24 2006 7:14 am
Subject: Re: RfD: SYNONYM

How slow do you want it. -;)

> I wonder how many missed the part in the spec about making
> aliases with the same name!

Not me I saw it.

> A conforming  SYNONYM  should be able to handle this:

>     \ Test SYNONYM ability to make alias with same name
>     CR
>     FORTH ALSO DEFINITIONS
>     : TEST  ." hello " ;
>     VOCABULARY NEWVOC
>     NEWVOC DEFINITIONS
>     SYNONYM TEST TEST  ( make alias in new vocab )
>     CR .( now testing alias ) CR
>     NEWVOC  TEST

Win32Forth supports that. I've used both SYNONYM and ALIAS (which
always makes the new word non-immediate irrespective of the immediacy
of the original) to have the same word in diffrent vocabularies many a
time. It's even used in the system for putting FORTH FORTH-WORDLIST and
SET-ORDER in the ROOT vocabulary (the one that's always available after
ONLY) as well as the FORTH vocabulary, so I know it works.

George Hubert


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alex McDonald  
View profile
 More options Aug 24 2006, 7:18 am
Newsgroups: comp.lang.forth
From: "Alex McDonald" <alex_...@btopenworld.com>
Date: 24 Aug 2006 04:18:35 -0700
Local: Thurs, Aug 24 2006 7:18 am
Subject: Re: RfD: SYNONYM

Are you sure? I've just run it under 6.11.07 and it fails.

--
Regards
Alex McDonald