I just found that the naming rules for dynamic temp-table fields differ from those for static temp-table fields.
This will not compile:
DEFINE TEMP-TABLE foo
FIELD Publisher(s) as CHARACTER.
This compiles (and works) just fine:
hTT:ADD-NEW-FIELD("Publisher(s)", "char", 0, "x(8)", "", "Publisher(s)", "Publisher(s)").
Has anyone else noticed this? Is it a bug? Feature?
Thanks,
Tom
Tom,
I have grabbed that case & will let you know what they say.
Brian
To allay the suspense... I agree - it is a bug.
hmm… I would say a ‘harmless’ one, and for backward compatibility sake hope this will still work :)
also,
in SQL there is the concept of "delimited identifiers" (i.e names enclosed in quotes) to get around problems like that and also names that conflict with keywords.
Using that idea, you would say
DEFINE TEMP-TABLE "find"
FIELD "Publisher(s)" as CHARACTER.
and then you could say find "find" where "Publisher(s)" = "Laura".
I have submitted bug number PSC00346838 for this.
Hey Brian, guess that depends on the driver after all… I can happily drive at full speed with quite large items on that console :)
the problem here is a general langauage syntax one - you want to name a vairable somethignthat looks like a functioncall.
this problem comes up in all programming languages. well mst of them anyhow. you wrote something that looks like def var x(i) as character. but variable names are nt allowed to have "(" or ")" characters in them and the compiler thinks this is a function call. Granted, the dynamic names do not follow the same rules and that is wrong.
Like it or not, you have to follow the naming rules. and those should be the same for static and dynamic names.
In this case, the error is that the dynamic rules are too lax and should have been more restrictive to match the static ones.
If we make them more restrictive, no one will be happy.
[quote user="tbergman"]
[quote user="tbergman"]
[quote user="gus"]
the problem here is a general langauage syntax one - you want to name a vairable somethignthat looks like a functioncall.
[/quote]
I have no desire to do such a thing, do understand the challenges of language parsing and won't advocate for having variable names that looks like function calls especially in an already ambiguous syntax as our good old 4gl :)
[quote user="gus"]
Granted, the dynamic names do not follow the same rules and that is wrong.
Like it or not, you have to follow the naming rules. and those should be the same for static and dynamic names.
[/quote]
I still don't see why this is so wrong, there is no technical reason to impose same restrictions as for static syntax (the prove is this just works)... it's not like a armed gun or anything that you can hurt others with, it's just a special one that one can use to shoot himself in the foot - hope those will be launched soon on idiegogo so we can way for Darwin to make the selection :)
It's true I can't do mytt::count(*) as that will also confuse the compiler but mytt:default-buffer-handle:buffer-field('count(*)') works just fine... you haven't heard me complaining for not being able to use the shortcut version did you? :)
Point is, this simply works as-is and for me adding restrictions just to make the dynamic handling 'consistent' with the static one is like forbidding birds to fly because mammals can't... oh wait, let me try a language I'm not very familiar with, from the business perspective what will be the justification to cover the development cost for 'fixing' that huge bug walking around free?
> On Apr 20, 2016, at 7:01 AM, marian.edu wrote:
>
> there is no technical reason to impose same restrictions as for static syntax (the prove is this just works)
sorry i was not being clear. let me try again.
what i meant to say is that the rules for static and dynamic should be the same and static ought to be changed to match the dynamic ones. The dynamic ones work because the names are in quotes. But Laura is the compiler expert and it is not for me to say how hard or practical such a change would be.
The one thing I just found that does not work is using our special bufHandle::<field-name> syntax to get the value of the field for a dynamic temp-table. E.g.:
DEF VAR tt AS HANDLE.
DEF VAR bhdl AS HANDLE.
CREATE TEMP-TABLE tt.
tt:ADD-NEW-FIELD("foo()", "Integer").
tt:TEMP-TABLE-PREPARE('mytt').
bhdl = tt:DEFAULT-BUFFER-HANDLE.
bhdl:BUFFER-CREATE().
MESSAGE bhdl::foo() VIEW-AS ALERT-BOX. /* You get a runtime error: BUFFER-FIELD foo was not found */
If I had made the name "foo(s)", that last line (with bhdl::foo(s)) will not even compile.
Indeed Laura,
Keywords like "character" ARE allowed - even in a statically defined table - much to my surprise!
[quote user="Laura Stern"] Keywords like "character" ARE allowed - even in a statically defined table - much to my surprise! [/quote]
Unfortunately "transaction" is not a legal TT field name, and that led to some inconsistent TT field names. :(