JohnOne Posted April 13, 2012 Share Posted April 13, 2012 I see, I might as well get this question out of the way too. Does this open up the possibility of function pointers, or is the functionality akin to that? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Valik Posted April 13, 2012 Author Share Posted April 13, 2012 (edited) From the user's perspective, yes, this is function pointers. I'm invoking built-in and user-defined functions indirectly through a variable. Don't let the missing $ confuse you, Writer (in the first example) is a variable. The $ is now optional in the language. The following code is equally valid and functionally equivalent: ConsoleWrite("AutoIt version: " & @AutoItVersion & @CRLF) Local $Writer = ConsoleWrite $Writer("What the hell, this works?" & @CRLF) $Writer = MyConsoleWrite $Writer("This works, too!?" & @CRLF) Func MyConsoleWrite($sText) ConsoleWrite("MyConsoleWrite(): " & sText) EndFunc Note that MyConsoleWrite() uses mixed $ and $-less variables. While this is possible and supported it's obviously stylistically undesirable and inconsistent. You should always use $ or never use $, not mixed. Edited April 13, 2012 by Valik Link to comment Share on other sites More sharing options...
guinness Posted April 13, 2012 Share Posted April 13, 2012 The $ is now optional in the language.I was about to ask this. Thanks. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
ProgAndy Posted April 14, 2012 Share Posted April 14, 2012 (edited) The $ is now optional in the language.This will break scripts if someone uses a variable called "$output" in a function called "output", right? Why don't you include the $ in the actual name of the variable, so that $var <> var? This would prevent breaking scripts and in my opinion this it would be a logical choice. Edited April 14, 2012 by ProgAndy czardas 1 *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
JohnOne Posted April 14, 2012 Share Posted April 14, 2012 I would have thought that internally autoit could distinguish between a function and a type variable. Hmmm, saying that, if a variable can be a pointer to a function, then a variable of type pointer might collide. But then a variable of typr pointer can only be created in a DllStruct as far as I know. I'm just confusing myself now. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Valik Posted April 14, 2012 Author Share Posted April 14, 2012 (edited) This will break scripts if someone uses a variable called "$output" in a function called "output", right? Why don't you include the $ in the actual name of the variable, so that $var <> var? This would prevent breaking scripts and in my opinion this it would be a logical choice.We will see how severe an impact this has. Right now my argument is you should have used better variable names including but not limited to some sort of type prefix.I would have thought that internally autoit could distinguish between a function and a type variable.Hmmm, saying that, if a variable can be a pointer to a function, then a variable of type pointer might collide.But then a variable of typr pointer can only be created in a DllStruct as far as I know.I'm just confusing myself now.The implementation for functions as first-class objects does not involve pointers. It only provides pointer-to-function like semantics from the language side. Internally it's implemented completely differently. Do not concern yourself with implementation details. What matters is that the feature works sensibly and how people expect. Which it does, barring a bug or two. Edited April 14, 2012 by Valik James 1 Link to comment Share on other sites More sharing options...
czardas Posted April 14, 2012 Share Posted April 14, 2012 I think it's really interesting feature. operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
funkey Posted April 14, 2012 Share Posted April 14, 2012 Very cool features! I always missed something like that! But what about highlighting variables in editor? Editor can not know what it is, or am i wrong. Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
Skitty Posted April 14, 2012 Share Posted April 14, 2012 One thing that I'd like to throw out there... Has anyone considered making it so that the autoit syntax would be like php? I mean wouldn't it be cool if we were able to create script's in one whole damn line? That would be a trip... Link to comment Share on other sites More sharing options...
Valik Posted April 14, 2012 Author Share Posted April 14, 2012 This will break scripts if someone uses a variable called "$output" in a function called "output", right? Why don't you include the $ in the actual name of the variable, so that $var <> var? This would prevent breaking scripts and in my opinion this it would be a logical choice.Actually no, you are not correct. I think. Variables with $ are not ambiguous. We know they are variables so AutoIt should only look in the variable table for it. It's only ambiguous when you use $-less names in which case AutoIt has to figure out if it's a variable or a function. I actually didn't look to see how trancexx handled this situation because obviously the situation produces a name conflict. Also as an aside, in theory $ variables will be faster (or functions will be slower) under the new system due to the ambiguity in $-less lookups requiring more work to resolve. So yeah, making $ optional should be fully backwards compatible. Link to comment Share on other sites More sharing options...
czardas Posted April 14, 2012 Share Posted April 14, 2012 (edited) I'm assuming that assigning a function name to a variable will also work for array elements. That is going to be something.pretty awesome. Maybe I worded that wong but the idea rocks. Edited April 14, 2012 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
ProgAndy Posted April 14, 2012 Share Posted April 14, 2012 (edited) I'm assuming that assigning a function name to a variable will also work for array elements. That is going to be something.pretty awesome. Wow. Two steps away from objects. I don't think it is going to happen, but let me dream Step 1: Associative Arrays with dot-access (arrya.key) Step 2: Something like Javascripts bind to preset parameters Result: Global $array[Assoc] $array.func = Bind(objectfunc, $array) $array.func("hello") Func objectfunc($self, $param) ConsoleWrite($param & @LF) EndFunc Edited April 14, 2012 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
czardas Posted April 14, 2012 Share Posted April 14, 2012 (edited) Wow. Two steps away from objects. I don't think it is going to happen, but let me dream It seems feasable, but what do I know? Edited April 14, 2012 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
matwachich Posted April 14, 2012 Share Posted April 14, 2012 Absolutly great new features!!! For when the final release is expected? Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted April 14, 2012 Share Posted April 14, 2012 Absolutly great new features!!!For when the final release is expected?When it's done.(you should have seen that coming ) .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Richard Robertson Posted April 14, 2012 Share Posted April 14, 2012 Func f() EndFunc Dim f = f f() Is this possible? Link to comment Share on other sites More sharing options...
Mat Posted April 14, 2012 Share Posted April 14, 2012 Will it be possible to pass these function pointers to *Register functions instead of strings? Ideally we'd never have to pass function names as strings. AutoIt Project Listing Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted April 14, 2012 Share Posted April 14, 2012 With the "function pointer" and array updates (seeing things unfolding on the repository before release is neato ) the next beta is going to be awesome! Great work trancexx! .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
jchd Posted April 14, 2012 Share Posted April 14, 2012 That's opening a new range of programming styles and constructs. I wouldn't say "paradigm" but this is great. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Valik Posted April 14, 2012 Author Share Posted April 14, 2012 Will it be possible to pass these function pointers to *Register functions instead of strings?Ideally we'd never have to pass function names as strings.Eventually we can modify the functions to accept the reference, yes. Right now, no, it's not implemented. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now