Alias keyword

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Andre.

Another request from a german PB user:

What do you think about an Alias() command, where the user could define own (maybe long-time used in other languages) command names for using instead/beside original PB command names ?

It should work this way:

Code: Select all

; must be constant strings, defined on top of the code
Alias(OriginalCommandName.s, NewCommandName.s)

; Examples
; Alias(";", "REM")
; Alias("OpenWindowedScreen", "OpenScr")

Regards
André

*** German PureBasic Support ***
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tinman.
Originally posted by Andre

Another request from a german PB user:

What do you think about an Alias() command, where the user could define own (maybe long-time used in other languages) command names for using instead/beside original PB command names ?
If Fred allows PB to have macros (v3.60? ;p) then you should be able to do this, and would be a better way than having a command specifically for it.

I do not think it is a good idea though. Why would a user bother to learn PB when they can make all their favourite commands from other languages appear?

And what happens when they ask for help with code which they have littered with aliases? OK, the code will still run, but the meaning and workings may be hidden, possibly preventing people from helping them.


--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + all updates, PB3.50)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by MrVainSCL.

Maybe and the only one way could be, to save the source with original purebasic commands, even if people use there own alias for any command. So the Editor have to load/save the source with the orginal pure commands and have to replace this to users screen... internal pure will handle ofcourse the original commands... so people could spread there sources (even if pure will save with original command set)... I think this topic was discused looooooong very looooong ago. On the other site i have really to agree with timan and in my eyes it dont make really sence to implent this feature to the editor next time.... Futuremore fred should fix known bugs and add new stuff, like doubles and more :wink:

greetz
MrVainSCL! aka Thorsten

PIII450, 256MB Ram, 80GB HD + 6,4 GB, RivaTNT, DirectX9.0, SB AWE64, Win2000 + all Updates...
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by MrVainSCL.

Btw... i remember that there was (or still is) a tool written in pure, which you can use with pure editor and write for example something like "-mr" and it will automatical write "MessageRequester" for example... so people can use there onw input commands and maybe to save some time instead using long commands :wink:

greetz
MrVainSCL! aka Thorsten

PIII450, 256MB Ram, 80GB HD + 6,4 GB, RivaTNT, DirectX9.0, SB AWE64, Win2000 + all Updates...
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Danilo.

I really want to see MACROs in v4.0 and afaik Fred
will add it.

Aliases are possible with MACROs too, but that doesnt
mean Fred shouldnt add MACROs because some users can
produce unreadable code with aliases.

MACROs can be very powerful, and for better WinAPI programming
it is really needed, IMHO.

If somebody wants to make shortcuts like 'OpenScr' for 'OpenScreen',
just let him do it with MACROs!

__PLEASE__ dont limit other users because you think you cant
read the code anymore.
If you read the source, the macros must be included - otherwise
the code cant compile (unknown command).
'OpenScr' is faster to type, so maybe the guy gets more productive
with using his own MACRO set!

cya,
...Danilo
(registered PureBasic user)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by horst.

Danilo,

100% agree.

I think there would be no discussion if the PB editor
had a pre-compiler interface, that means, any program
could be run to convert the source to proper BP code before
the compiler takes over.

Anyone could run or write his favorite pre-compiler, and
this program would also convert the source to pure PB code
for other users, when necessary.

No discussion, what is best - just absolute freedom.

In any case, I'll probably write my own pre-compiler that
handles aliases and simple macros. Until there is an
interface I just use my own launch pad for compilation.


Horst
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Andre.

Thanks four your suggestions, guys
With all your input I would also prefer the MACRO's. So I will forward this information now... :)

Regards
André

*** German PureBasic Support ***
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> Btw... i remember that there was (or still is) a tool written in
> pure, which you can use with pure editor and write for example
> something like "-mr" and it will automatical write "MessageRequester"
> for example... so people can use there onw input commands and maybe
> to save some time instead using long commands :wink:

That app was my own PBToolBox, and can be downloaded from here:

http://tinyurl.com/56ws

I was going to put the auto-complete code into the official editor,
but not any more due to political reasons.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by TheBeck.

> I think there would be no discussion if the PB editor
> had a pre-compiler interface

You can do this now! You don't even have to touch the editor source. Just rename the PB compiler file and put your program where the compiler was, using compiler's old name and call the re-named compiler after your code is done. This would work, wouldn't it?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> Just rename the PB compiler file and put your program where the
> compiler was, using compiler's old name and call the re-named
> compiler after your code is done. This would work, wouldn't it?

Interesting concept! I'll have to play around with this idea! :)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tinman.
Originally posted by Danilo

__PLEASE__ dont limit other users because you think you cant
read the code anymore.
If you read the source, the macros must be included - otherwise
the code cant compile (unknown command).
I agree with you but the first time I wrote my reply my internet connection went down, and the second version of my reply came out wrong :)

I don't want to see PB limiting users as that would (possibly) also limit me. I think macros are very much of a high requirement, and what people do with them is up to them. I don't think a command specifically for aliasing command names is a good idea.

Sure, you can say 'OpenScr' is faster than 'OpenScreen(...,...,...,etc)' but at what point does your code become unrecognisable? Yes, all the macros will be in their code (although how many times do we see people posting incomplete code?), but are you saying that you would be willing to look through someone's macro definitions which redefines *all* PB commands to their own names and parameters in case the bug is there? (Yes, I know it's unlikely someone would redefine all the commands, but they could.)

You've also picked a sensible name for your macro. What about the people who don't - their code will be more difficult to read.

I'm not saying macros or redefining commands is a bad thing, but I don't think it needs to be actively supported by specific commands. I guess it's all relative whether you see this kind of thing a hassle at some point or not at all.


PB - You know you could just have your program as an external tool that gets called before the compiler runs over the source, using the new editor? In the tools menu. Update: Oops, I thought you could get tools to run automatically before compiling, but I had a look at the tolls editor and it looks like the user would still need to manually run the tool before compiling.

--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + all updates, PB3.50)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by freak.

> Just rename the PB compiler file and put your program where the
> compiler was, using compiler's old name and call the re-named
> compiler after your code is done. This would work, wouldn't it?

This is NOT a very good idea! If the Editor starts the Compiler, it saves the ProcessID, to end the Compiler when you close the Editor. If you do this, the Editor is only going to end your App, and the Compiler would remain running.

If the User restarts the Editor several times, you'll have a lot of PBCompiler.exe's running which you can olny close with TaskManager.

Timo
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by horst.

TheBeck:

> Just rename the PB compiler file and put your program where
> the compiler was, using compiler's old name and call the
> re-named compiler after your code is done.

Yeah, that probably works.
However, the Compile/Run (F5) command seems to compile from
a temporary file, so I have to figure out, how I can get the
directory of the original source file (for possible includes)...


Horst
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by MrVainSCL.

Macros and Fred for ever ;-D

greetz
MrVainSCL! aka Thorsten

PIII450, 256MB Ram, 80GB HD + 6,4 GB, RivaTNT, DirectX9.0, SB AWE64, Win2000 + all Updates...
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by El_Choni.
by freak:

This is NOT a very good idea! If the Editor starts the Compiler, it saves the ProcessID, to end the
Compiler when you close the Editor. If you do this, the Editor is only going to end your App, and the Compiler would remain running.

If the User restarts the Editor several times, you'll have a lot of PBCompiler.exe's running which you can olny close with TaskManager.
But the pre-compiler program can do the same: save the compiler program ProcessID and make it a child process. When the editor closes the pre-compiler, compiler will also close, won't it?

Just a thought, bye,

El_Choni
Post Reply