At the moment the creation of any callback procedures requrie the use fo a procedure name. This clutter both the code and the global namespace.
For example, at the moment a windows callback would be set as follows:
Code: Select all
Procedure MyWindowCallback(WindowID, Message, wParam, lParam)
Result = #PB_ProcessPureBasicEvents
;
; you code here
;
ProcedureReturn Result
EndProcedure
SetWindowCallback(@MyWindowCallback)
If I had another window with the same callback name I would get a nameclash, making it necessary to use naming conventions if a file is to be reused.
An anonymous callback would allow the following:
Code: Select all
*MyWindowCallback = Callback(WindowID, Message, wParam, lParam)
Result = #PB_ProcessPureBasicEvents
;
; you code here
;
ProcedureReturn Result
EndCallback
SetWindowCallback(*MyWindowCallback)
It could be that a callback declaration could be useed a procedure call (on the same line. In this case a pointer to the callback will be passed to the procedure. The code would look like this:
Code: Select all
SetWindowCallback(Callback(WindowID, Message, wParam, lParam))
Result = #PB_ProcessPureBasicEvents
;
; you code here
;
ProcedureReturn Result
EndCallback
Anybody who has used Ruby will know just how useful this type of callback can be.
Any thoughts?