Re: What if jQuery was written in Tcl?



Thanks Donal - lots of interesting stuff in here :)

Actually, you want this:

  proc lambda {arglist body {ns {}}} {
      if {$ns eq ""} {set ns [uplevel 1 namespace current]}
      list apply [list $arglist $body $ns]
  }

Ah, to capture the namespace in which you're executing, so that
command resolution and [variable] work correctly.

Contrast 'jQuery(elem).html(data)' against '[jQuery $elem] html $data'
Is there a better way to do this?

Unless you make the methods themselves process this, it's difficult.
The issue is that Tcl's very strongly variadic, and that doesn't sit
too well with chaining.

Yes, I thought this may be one of the hardest to address given Tcl's
syntax.




- jQuery's selector language uses the character '[' to address
attributes, and this requires quoting in Tcl.

This is common when embedding foreign languages in Tcl. More awkward
is the fact that it makes substituting in Tcl variables/command-
results difficult. Perhaps this is an area where a leaf can be taken
out of sqlite's/TDBC's book?

I'm not sure I follow. Are you referring to the TDBC mechanism that
required the DB interface to substitute :varname in a SQL statement
with the value of the correspoding variable the dict handed to '$db
execute' (and quote it appropriately). That method is specific to
SQL's syntax; are you suggesting a similar language-specific rule for
every embedded foreign language?

dict on the fly. Tcl has no syntax to construct a large list or dict
with substituted/evaluated content without using line continuation
(which is inconvenient, ugly and error prone, IMO).

syntax makes a big difference). However, this is a language limitation
imposed by a combination of using line end as a command terminator and
extreme flexibility; there's no way to tell that the end of a command
invocation has been reached at the syntactic level. These are

I think the proposed parentheses rule for Cloverfield (http://
wiki.tcl.tk/20643) is close to the right approach. It would allow
round brackets (...) to replace [list ...], but line endings within
the (...) are treated as whitespace (not command terminators).

A more radical change would allow (...) but not allow barewords (but
elements starting with $ or [ would be allowed and processed as
expected), and treat ',', '=' and '->' as whitespace.

That allows you to do this:
set a (
"key" -> value,
"another key" -> {
some body of information
},
$substkey = $substvalue,
[get_key] = (subs list or dict)
)

I'm mixing the '->' and '=' syntax in there so it may look a little
noisier than necessary, but I think this gives us something very much
like JavaScript, Ruby & Python have.

- [dict get $var key] just doesn't compare to $var.key for readability

Such major syntax changes would have broken *lots* of scripts. Which
isn't to say that they're forbidden for the future when we do a major
language version. (Perhaps “$var->key” would work?)

Ick. -> is an ugly syntax ;p It's also most commonly found in C for
dereferencing via pointers, so $varname->key should mean something
like 'upvar $varname v ; $v.key' imho.

I think period-separation is widely used (C, Java, JavaScript and
highly readable.

The proposed rules for Cloverfield look ... dodgy.

- The [jQuery] calls each return an object ... what happens to that
object?

If you can establish ownership of the object (at the non-package
level) by another object in a UML-style containment relationship, then
we can do cleanup automatically in TclOO.

'Can' as in it happens, or 'can' as in put code in the destructor?

An alternative approach is to do something constructive with leading-
word-expansion and return some sort of anonymous function instead of
an object, preserving EIAS (hopefully).

The value/command dichotomy discussion in the Wiki (http://wiki.tcl.tk/
8703) is probably relevant here, I just haven't figured out how yet ;)

Regards,
Twylite
.



Relevant Pages

  • Re: How to detach from remote command?
    ... as the user running the at command at the time specified. ... and the syntax is unclear, with no examples in the man page. ... One site suggested building the command interactively as: ... can get by with your syntax, which would include executing ...
    (comp.os.linux)
  • Re: Problems installing XP SP2!
    ... package source directory and make sure the that XPSPS2sms.exe file exists in ... in your SMS Program command line property. ... > Executing program as a script ... > OnOptionalExecutionRequests failed for program Automated upgrade from XP ...
    (microsoft.public.sms.admin)
  • Re: Windows update error 0x80242008
    ... 2.219: Hotfix started with following command line: /si ... Unexpected Error While Executing Line 1 ( ... Test.IE7InstallBlock.Section) of PreRequisite ...
    (microsoft.public.windowsupdate)
  • Re: Accesing structures data (getting lengthy!)
    ... According to the syntax you ... assignment statement just won't stand out amongst all the other ... meaningless dummy variables that you have to keep track of. ... comparitively easy to pick out of a long, boring, command line history, ...
    (comp.soft-sys.matlab)
  • Re: Windows could not upgrade the file..........Security update KB
    ... "Sky King" wrote in message ... > Robert Aldwinckle wrote: ... I would not have offered my tip about copying text from a command ... probably over a simple syntax error. ...
    (microsoft.public.windowsupdate)

Loading