Короткие теги не включены по умолчанию в некоторых веб-серверах (совместно использованные хосты, и т.д.), таким образом переносимость кода становится проблемой, если необходимо переместиться в один из них.
Удобочитаемость может быть проблемой для некоторых. Многие разработчики могут найти, что привлекает внимание как более очевидный маркер начала блока кода, чем
, когда Вы сканируете файл, особенно если Вы застреваете с кодовой базой с HTML и PHP, плотно вплетенный.
From your code, function g takes a string parameter and returns a string. I suggest you create a class module called IStringFunction to act as the definition of an interface that all functions will support, thus:
Class Module: IStringFunction
Public Function Evaluate(ByVal s As String) As String
End Function
Then, create a couple of example functions implementing this interface:
Class Module: HelloStringFunction
Implements IStringFunction
Public Function IStringFunction_Evaluate(ByVal s As String) As String
IStringFunction_Evaluate = "hello " & s
End Function
Class Module: GoodbyeStringFunction
Implements IStringFunction
Public Function IStringFunction_Evaluate(ByVal s As String) As String
IStringFunction_Evaluate = "goodbye " & s
End Function
...and finally, some test code to exercise the functions:
(Standard) Module: Test
Sub Test()
Dim oHello As New HelloStringFunction
Dim oGoodbye As New GoodbyeStringFunction
MsgBox Evaluate(oHello, "gary")
MsgBox Evaluate(oGoodbye, "gary")
End Sub
Private Function Evaluate(ByVal f As IStringFunction, ByVal arg As String) As String
Evaluate = f.Evaluate(arg)
End Function
Note that the class implementing the interface must have methods named
as in the example above, not just
as you'd expect.
Download the simple demo or intermediate demo here